Skip to content

Commit 5b9e980

Browse files
authored
feat: add engine.bare frontmatter field to suppress automatic context loading (#25661)
1 parent 17dff22 commit 5b9e980

17 files changed

+589
-59
lines changed

.changeset/patch-add-engine-bare-frontmatter-field.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-claude.lock.yml

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-claude.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ name: Smoke Claude
1919
engine:
2020
id: claude
2121
max-turns: 100
22+
bare: true
2223
strict: false
2324
inlined-imports: true
2425
imports:

.github/workflows/smoke-copilot.lock.yml

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ name: Smoke Copilot
1919
engine:
2020
id: copilot
2121
max-continuations: 2
22+
bare: true
2223
imports:
2324
- shared/github-guard-policy.md
2425
- shared/gh.md

pkg/parser/schemas/main_workflow_schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9253,6 +9253,11 @@
92539253
"type": "string"
92549254
},
92559255
"description": "Optional array of command-line arguments to pass to the AI engine CLI. These arguments are injected after all other args but before the prompt."
9256+
},
9257+
"bare": {
9258+
"type": "boolean",
9259+
"description": "When true, disables automatic loading of context and custom instructions by the AI engine. The engine-specific flag depends on the engine: copilot uses --no-custom-instructions (suppresses .github/AGENTS.md and user-level custom instructions), claude uses --bare (suppresses CLAUDE.md memory files), codex uses --no-system-prompt (suppresses the default system prompt), gemini sets GEMINI_SYSTEM_MD=/dev/null (overrides the built-in system prompt with an empty one). Defaults to false.",
9260+
"default": false
92569261
}
92579262
},
92589263
"required": ["id"],
@@ -9374,6 +9379,11 @@
93749379
}
93759380
},
93769381
"additionalProperties": false
9382+
},
9383+
"bare": {
9384+
"type": "boolean",
9385+
"description": "When true, disables automatic loading of context and custom instructions by the AI engine. The engine-specific flag depends on the engine: copilot uses --no-custom-instructions, claude uses --bare, codex uses --no-system-prompt, gemini sets GEMINI_SYSTEM_MD=/dev/null. Defaults to false.",
9386+
"default": false
93779387
}
93789388
},
93799389
"required": ["runtime"],

pkg/workflow/agent_validation.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// This file validates agent-specific configuration and feature compatibility
66
// for agentic workflows. It ensures that:
77
// - Custom agent files exist when specified
8-
// - Engine features are supported (HTTP transport, max-turns, web-search)
8+
// - Engine features are supported (HTTP transport, max-turns, web-search, bare mode)
99
// - Workflow triggers have appropriate security constraints
1010
//
1111
// # Validation Functions
@@ -14,6 +14,7 @@
1414
// - validateMaxTurnsSupport() - Validates max-turns feature support
1515
// - validateMaxContinuationsSupport() - Validates max-continuations feature support
1616
// - validateWebSearchSupport() - Validates web-search feature support (warning)
17+
// - validateBareModeSupport() - Validates bare mode feature support (warning)
1718
// - validateWorkflowRunBranches() - Validates workflow_run has branch restrictions
1819
//
1920
// # Validation Patterns
@@ -174,6 +175,25 @@ func (c *Compiler) validateWebSearchSupport(tools map[string]any, engine CodingA
174175
}
175176
}
176177

178+
// validateBareModeSupport validates that bare mode is only used with engines that support this feature.
179+
// Emits a warning and has no effect on engines that do not support bare mode.
180+
func (c *Compiler) validateBareModeSupport(frontmatter map[string]any, engine CodingAgentEngine) {
181+
_, engineConfig := c.ExtractEngineConfig(frontmatter)
182+
183+
if engineConfig == nil || !engineConfig.Bare {
184+
// bare mode not requested, no validation needed
185+
return
186+
}
187+
188+
agentValidationLog.Printf("Validating bare mode support for engine: %s", engine.GetID())
189+
190+
if !engine.SupportsBareMode() {
191+
agentValidationLog.Printf("Engine %s does not support bare mode, emitting warning", engine.GetID())
192+
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Engine '%s' does not support bare mode (engine.bare: true). Bare mode is only supported for the 'copilot' and 'claude' engines. The setting will be ignored.", engine.GetID())))
193+
c.IncrementWarningCount()
194+
}
195+
}
196+
177197
// validateWorkflowRunBranches validates that workflow_run triggers include branch restrictions
178198
// This is a security best practice to avoid running on all branches
179199
func (c *Compiler) validateWorkflowRunBranches(workflowData *WorkflowData, markdownPath string) error {

pkg/workflow/agentic_engine.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ type GitHubActionStep []string
3838
// CapabilityProvider (feature detection - optional)
3939
// ├── SupportsToolsAllowlist()
4040
// ├── SupportsMaxTurns()
41-
// └── SupportsWebSearch()
41+
// ├── SupportsWebSearch()
42+
// ├── SupportsMaxContinuations()
43+
// ├── SupportsNativeAgentFile()
44+
// └── SupportsBareMode()
4245
//
4346
// WorkflowExecutor (compilation - required)
4447
// ├── GetDeclaredOutputFiles()
@@ -123,6 +126,11 @@ type CapabilityProvider interface {
123126
// the agent file content in prompt.txt during the activation job so that the engine just
124127
// reads the standard /tmp/gh-aw/aw-prompts/prompt.txt as usual.
125128
SupportsNativeAgentFile() bool
129+
130+
// SupportsBareMode returns true if this engine supports the bare mode feature
131+
// (engine.bare: true), which suppresses automatic loading of context and custom
132+
// instructions. When false, specifying bare: true emits a warning and has no effect.
133+
SupportsBareMode() bool
126134
}
127135

128136
// WorkflowExecutor handles workflow compilation and execution
@@ -268,6 +276,7 @@ type BaseEngine struct {
268276
supportsMaxContinuations bool
269277
supportsWebSearch bool
270278
supportsNativeAgentFile bool
279+
supportsBareMode bool
271280
llmGatewayPort int
272281
}
273282

@@ -307,6 +316,10 @@ func (e *BaseEngine) SupportsNativeAgentFile() bool {
307316
return e.supportsNativeAgentFile
308317
}
309318

319+
func (e *BaseEngine) SupportsBareMode() bool {
320+
return e.supportsBareMode
321+
}
322+
310323
func (e *BaseEngine) getLLMGatewayPort() int {
311324
return e.llmGatewayPort
312325
}

pkg/workflow/claude_engine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func NewClaudeEngine() *ClaudeEngine {
3030
supportsMaxContinuations: false, // Claude Code does not support --max-autopilot-continues-style continuation
3131
supportsWebSearch: true, // Claude has built-in WebSearch support
3232
supportsNativeAgentFile: false, // Claude does not support agent file natively; the compiler prepends the agent file content to prompt.txt
33+
supportsBareMode: true, // Claude CLI supports --bare
3334
llmGatewayPort: constants.ClaudeLLMGatewayPort,
3435
},
3536
}
@@ -162,6 +163,13 @@ func (e *ClaudeEngine) GetExecutionSteps(workflowData *WorkflowData, logFile str
162163
// This format is compatible with the log parser which expects either JSON array or JSONL
163164
claudeArgs = append(claudeArgs, "--output-format", "stream-json")
164165

166+
// Add --bare when bare mode is enabled to suppress automatic loading of memory
167+
// files (CLAUDE.md, ~/.claude/) and other context injections.
168+
if workflowData.EngineConfig != nil && workflowData.EngineConfig.Bare {
169+
claudeLog.Print("Bare mode enabled: adding --bare")
170+
claudeArgs = append(claudeArgs, "--bare")
171+
}
172+
165173
// Add custom args from engine configuration before the prompt
166174
if workflowData.EngineConfig != nil && len(workflowData.EngineConfig.Args) > 0 {
167175
claudeArgs = append(claudeArgs, workflowData.EngineConfig.Args...)

pkg/workflow/codex_engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ touch %s
255255
(umask 177 && touch %s)
256256
INSTRUCTION="$(cat "$GH_AW_PROMPT")"
257257
mkdir -p "$CODEX_HOME/logs"
258-
%s %sexec%s%s%s%s"$INSTRUCTION" 2>&1 | tee %s`, AgentStepSummaryPath, logFile, commandName, modelParam, webSearchParam, webFetchParam, fullAutoParam, customArgsParam, logFile)
258+
%s 2>&1 | tee %s`, AgentStepSummaryPath, logFile, codexCommand, logFile)
259259
}
260260

261261
// Get effective GitHub token based on precedence: custom token > default

0 commit comments

Comments
 (0)