feat: add engine.bare frontmatter field to suppress automatic context loading#25661
feat: add engine.bare frontmatter field to suppress automatic context loading#25661
Conversation
…loading - Add `Bare bool` to `EngineConfig` struct in engine.go - Parse `bare` field in `ExtractEngineConfig` - copilot: adds `--no-custom-instructions` when bare=true - claude: adds `--bare` when bare=true - codex: adds `--no-system-prompt` (global flag, before exec subcommand) when bare=true - gemini: sets `GEMINI_SYSTEM_MD=/dev/null` env var when bare=true - Add `bare` boolean property to engine_config JSON schema - Add unit tests for parsing and per-engine behavior - Add integration tests for all four engines" Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d4a44b40-a9c2-494e-ae67-bb4b913258ef Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…at strings Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d4a44b40-a9c2-494e-ae67-bb4b913258ef Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
|
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready. |
Agent Container Tool Check
Result: 12/12 tools available ✅ Overall Status: PASS
|
There was a problem hiding this comment.
Pull request overview
Adds an engine.bare: true/false frontmatter option (defaulting to false) to suppress each engine’s automatic loading of built-in/system instructions or memory/context sources, by injecting engine-specific CLI flags or environment overrides.
Changes:
- Extend
EngineConfigand frontmatter parsing to supportengine.bare. - Inject per-engine “bare mode” behavior into Copilot/Claude/Codex/Gemini execution step generation.
- Add/update unit + integration tests and JSON schema documentation for the new field.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/engine.go | Adds Bare to EngineConfig and parses engine.bare from frontmatter. |
| pkg/workflow/copilot_engine_execution.go | Appends --no-custom-instructions when bare: true. |
| pkg/workflow/claude_engine.go | Appends --bare when bare: true. |
| pkg/workflow/codex_engine.go | Adds --no-system-prompt as a global flag before exec when bare: true; refactors command string reuse. |
| pkg/workflow/gemini_engine.go | Sets GEMINI_SYSTEM_MD=/dev/null when bare: true (unless already set by config). |
| pkg/workflow/engine_config_test.go | Adds unit tests for engine.bare extraction and per-engine args/env injection. |
| pkg/workflow/engine_args_integration_test.go | Adds integration tests verifying compiled YAML includes the expected bare-mode flags/env. |
| pkg/parser/schemas/main_workflow_schema.json | Documents and schemas the new engine.bare boolean field. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 3
| // Extract optional 'bare' field (disable automatic context/instruction loading) | ||
| if bare, hasBare := engineObj["bare"]; hasBare { | ||
| if bareBool, ok := bare.(bool); ok { | ||
| config.Bare = bareBool | ||
| engineLog.Printf("Extracted bare mode: %v", config.Bare) | ||
| } | ||
| } |
There was a problem hiding this comment.
engine.bare is only extracted in the non-inline (engine.id) parsing path. When engine.runtime is used (inline engine definition), ExtractEngineConfig returns early before reaching this block, so bare: true will be silently ignored for inline definitions. If bare mode is intended to work for inline engines too, parse/apply bare before the early return (or in the runtime branch as well) and add a regression test for engine: { runtime: {…}, bare: true }. If it is intentionally unsupported for inline engines, it should be documented and ideally rejected via schema validation to avoid a silent no-op.
pkg/workflow/gemini_engine.go
Outdated
| // When bare mode is enabled, set GEMINI_SYSTEM_MD to /dev/null to override the | ||
| // built-in system prompt with an empty one. This is the only supported mechanism | ||
| // to suppress Gemini CLI's default context loading (no dedicated CLI flag exists). | ||
| // engine.env (applied above) takes precedence: if the user explicitly sets | ||
| // GEMINI_SYSTEM_MD there, we skip the bare-mode default so their value wins. | ||
| if workflowData.EngineConfig != nil && workflowData.EngineConfig.Bare { | ||
| geminiLog.Print("Bare mode enabled: setting GEMINI_SYSTEM_MD=/dev/null") | ||
| if _, alreadySet := env["GEMINI_SYSTEM_MD"]; !alreadySet { | ||
| env["GEMINI_SYSTEM_MD"] = "/dev/null" | ||
| } | ||
| } |
There was a problem hiding this comment.
The comment and behavior here only guard against engine.env overriding the bare-mode default, but agentConfig.Env is merged later and can still overwrite GEMINI_SYSTEM_MD after this block. That makes the stated precedence inaccurate and can also make the log line misleading (it logs "setting" even when it ends up overridden). Consider moving the bare-mode default assignment to after all user-provided env merges (engine.env and agent env), and only logging when the assignment actually happens (or log a distinct "already set; leaving as-is" message).
See below for a potential fix:
// Add custom environment variables from agent config
agentConfig := getAgentConfig(workflowData)
if agentConfig != nil && len(agentConfig.Env) > 0 {
maps.Copy(env, agentConfig.Env)
geminiLog.Printf("Added %d custom env vars from agent config", len(agentConfig.Env))
}
// When bare mode is enabled, set GEMINI_SYSTEM_MD to /dev/null to override the
// built-in system prompt with an empty one. This is the only supported mechanism
// to suppress Gemini CLI's default context loading (no dedicated CLI flag exists).
// User-provided env values (from engine.env and agent env, both applied above)
// take precedence: if GEMINI_SYSTEM_MD is already set, leave it unchanged.
if workflowData.EngineConfig != nil && workflowData.EngineConfig.Bare {
if _, alreadySet := env["GEMINI_SYSTEM_MD"]; !alreadySet {
geminiLog.Print("Bare mode enabled: setting GEMINI_SYSTEM_MD=/dev/null")
env["GEMINI_SYSTEM_MD"] = "/dev/null"
} else {
geminiLog.Print("Bare mode enabled: GEMINI_SYSTEM_MD already set; leaving as-is")
}
}
| "bare": { | ||
| "type": "boolean", | ||
| "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.", | ||
| "default": false | ||
| } |
There was a problem hiding this comment.
Schema adds engine.bare only to the { id: ... } engine config shape. Inline engine definitions (engine: { runtime: { ... } }) still cannot specify bare, and the compiler currently ignores bare for inline definitions as well. If bare mode should be supported uniformly, add bare to the inline-engine schema branch too (and ensure the compiler parses it). Otherwise, consider explicitly documenting this limitation in the schema description to avoid confusing users.
|
Smoke test run
|
🧪 Test Quality Sentinel ReportTest Quality Score: 70/100
Test Classification DetailsView all 14 tests
Flagged Tests — Requires Review
|
| Component | Weight | Score | Notes |
|---|---|---|---|
| Behavioral Coverage | 40 pts | 40/40 | 100% design tests |
| Error/Edge Case Coverage | 30 pts | 15/30 | 7/14 tests include negative or edge cases |
| Low Duplication | 20 pts | 15/20 | 1 duplicate cluster (8 near-identical engine×flag tests) |
| Proportional Growth | 10 pts | 0/10 | Test inflation: 449 test lines added vs ~43 production lines (≈10:1) |
Note on inflation: The high ratio is understandable — the feature adds a single
Bare boolfield toEngineConfig, but tests must cover each engine (copilot, claude, codex, gemini) × mode (true, false) × level (unit, integration). The inflation flag is applied mechanically per the rubric, not as a quality concern.
Language Support
Tests analyzed:
- 🐹 Go (
*_test.go): 14 tests — integration (//go:build integration: 4) and unit (//go:build !integration: 10) - 🟨 JavaScript (
*.test.cjs,*.test.js): 0 tests
Verdict
✅ Check passed. 0% of new tests are implementation tests (threshold: 30%). No coding-guideline violations detected. All 14 tests verify observable behavioral contracts. The one reliability concern (
TestEngineBareModeCodex_BeforeExec) is a test effectiveness issue but not a correctness one.
📖 Understanding Test Classifications
Design Tests (High Value) verify what the system does:
- Assert on observable outputs, return values, or state changes
- Cover error paths and boundary conditions
- Would catch a behavioral regression if deleted
- Remain valid even after internal refactoring
Implementation Tests (Low Value) verify how the system does it:
- Assert on internal function calls (mocking internals)
- Only test the happy path with typical inputs
- Break during legitimate refactoring even when behavior is correct
- Give false assurance: they pass even when the system is wrong
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
🧪 Test quality analysis by Test Quality Sentinel · ● 878.8K · ◷
There was a problem hiding this comment.
✅ Test Quality Sentinel: 70/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). All 14 new tests verify behavioral contracts across 4 engines (copilot, claude, codex, gemini) with correct build tags and no mock-library violations. One minor reliability gap flagged in TestEngineBareModeCodex_BeforeExec — see the detailed comment for a suggested fix.
|
Smoke Test Run §24248606598 Core: ✅1 ✅2 ✅3 ✅4 ✅5 ✅6 ✅7 ✅8 ✅9 ✅10 ✅11 ✅12 Overall: PARTIAL (2 skipped — thread resolve & close PR, 0 failed)
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
💥 [THE END] — Illustrated by Smoke Claude · ● 197.2K
| // Add --bare when bare mode is enabled to suppress automatic loading of memory | ||
| // files (CLAUDE.md, ~/.claude/) and other context injections. | ||
| if workflowData.EngineConfig != nil && workflowData.EngineConfig.Bare { | ||
| claudeLog.Print("Bare mode enabled: adding --bare") |
There was a problem hiding this comment.
The --bare flag placement looks correct — added before custom args, which is the right order for Claude CLI. One minor nit: the log message says "adding --bare" but it might be clearer to say "suppressing CLAUDE.md context via --bare" to match the intent documented in the schema description.
| Args []string | ||
| Agent string // Agent identifier for copilot --agent flag (copilot engine only) | ||
| APITarget string // Custom API endpoint hostname (e.g., "api.acme.ghe.com" or "api.enterprise.githubcopilot.com") | ||
| Bare bool // When true, disables automatic loading of context/instructions (copilot: --no-custom-instructions, claude: --bare, codex: --no-system-prompt, gemini: GEMINI_SYSTEM_MD=/dev/null) |
There was a problem hiding this comment.
The inline comment on Bare is comprehensive and cross-references all four engines — good for maintainers discovering this field later. Consider also adding a reference to the frontmatter schema so readers can find the user-facing docs from the struct definition.
|
🤖 Smoke test run §24248606547 — PASS ✅
cc
|
There was a problem hiding this comment.
PR adds engine.bare to suppress automatic context loading across all four engines. Implementation is clean and consistent. One style note on codex_engine.go re: trailing-space string concatenation vs. slice append — see inline comment. No blocking issues.
📰 BREAKING: Report filed by Smoke Copilot · ● 1.1M
| // Add --bare when bare mode is enabled to suppress automatic loading of memory | ||
| // files (CLAUDE.md, ~/.claude/) and other context injections. | ||
| if workflowData.EngineConfig != nil && workflowData.EngineConfig.Bare { | ||
| claudeLog.Print("Bare mode enabled: adding --bare") |
There was a problem hiding this comment.
Nice clean implementation! The nil-guard workflowData.EngineConfig != nil is consistent with the pattern used for Args below. One minor observation: the debug log here uses claudeLog.Print (without f), which is fine for a static string. The pattern is consistent across engines. ✅
pkg/workflow/codex_engine.go
Outdated
| bareGlobalParam := "" | ||
| if workflowData.EngineConfig != nil && workflowData.EngineConfig.Bare { | ||
| codexEngineLog.Print("Bare mode enabled: adding --no-system-prompt") | ||
| bareGlobalParam = "--no-system-prompt " |
There was a problem hiding this comment.
The bareGlobalParam string uses a trailing space as a separator ("--no-system-prompt "). This is a bit fragile — if the format string ever changes, a stray space or a double-space could appear. Consider appending "--no-system-prompt" as a separate element in a slice, consistent with how claudeArgs handles this in claude_engine.go.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
Commit pushed:
|
|
@copilot set smoke-claude and smoke-copilot to bare |
…ng, add to smoke workflows - Parse engine.bare in inline engine definition path (engine.runtime) too - Move Gemini GEMINI_SYSTEM_MD bare-mode assignment to after all env merges (engine.env and agent env) so user values properly take precedence - Add bare field to inline engine schema branch - Add bare: true to smoke-claude and smoke-copilot workflows - Add regression test TestExtractEngineConfig_InlineDefinition_Bare Agent-Logs-Url: https://github.com/github/gh-aw/sessions/14c9b981-728b-42d6-b04f-01581ae788d0 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 21d5061 — added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Remove changes for codex, Gemini. Show warning as unsupported instead. Add function to agentic engine interface to determine if supported. |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/14c9b981-728b-42d6-b04f-01581ae788d0 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…/gemini with warning - Add SupportsBareMode() bool to CapabilityProvider interface - Add supportsBareMode field and SupportsBareMode() default (false) to BaseEngine - Set supportsBareMode: true on copilot (--no-custom-instructions) and claude (--bare) - Remove bare mode implementation from codex (--no-system-prompt) and gemini (GEMINI_SYSTEM_MD) - Add validateBareModeSupport() to agent_validation.go: warns when bare is set on an unsupported engine - Call validateBareModeSupport from compiler_orchestrator_tools.go - Update tests: remove codex/gemini bare tests, add SupportsBareMode capability tests and unsupported engine warning integration tests Agent-Logs-Url: https://github.com/github/gh-aw/sessions/f70330b6-ea05-4f4d-9826-9246f777333d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 69d6b96. Removed bare mode implementations for codex and gemini. Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot merge main, recompile, fix conflicts |
…re-field # Conflicts: # pkg/workflow/codex_engine.go Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 6f64905. Merged Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot merge main, fix conflicts, recompile |
…re-field # Conflicts: # pkg/workflow/codex_engine.go Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in e376357. Merged Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Adds
engine.bare: true/false(defaultfalse) to disable automatic loading of instructions and context by the AI engine — useful when you want full control over what the agent sees.Bare mode is supported by
copilotandclaudeonly. Specifyingengine.bare: truefor an unsupported engine emits a compiler warning and has no effect.Per-engine behavior
copilot--no-custom-instructions.github/AGENTS.md, user-level custom instructionsclaude--bareCLAUDE.mdmemory files, user configurationcodexgeminiengine.bareworks for both regular (engine: { id: ... }) and inline (engine: { runtime: { id: ... } }) engine definitions.Usage
Changes
engine.go—Bare boolfield added toEngineConfig+ frontmatter parsing (both regular and inline definition paths)agentic_engine.go—SupportsBareMode() booladded toCapabilityProviderinterface; defaultfalseinBaseEnginecopilot_engine.go—supportsBareMode: true; injects--no-custom-instructionswhenbare: trueclaude_engine.go—supportsBareMode: true; injects--barewhenbare: truecodex_engine.go—supportsBareMode: false(default); bare mode is ignored at execution levelgemini_engine.go—supportsBareMode: false(default); bare mode is ignored at execution levelagent_validation.go—validateBareModeSupport()emits a warning whenbare: trueis used with an engine that does not support itcompiler_orchestrator_tools.go— callsvalidateBareModeSupport()during compilationmain_workflow_schema.json—bareboolean added to both the{ id: ... }and inline{ runtime: { ... } }engine config schema branchessmoke-claude.md/smoke-copilot.md— enabledbare: trueon the smoke test workflows✨ PR Review Safe Output Test - Run 24248606598
Changeset
engine.barefrontmatter option that suppresses automatic context loading for supported engines.