feat(environment): introduce disable_omo_env configuration option

- Added a new configuration option `disable_omo_env` to control the injection of the `<omo-env>` block in agent prompts.
- Updated relevant functions and tests to support this feature, ensuring that the environment context can be toggled on or off as needed.
- Enhanced documentation to reflect the new option and its implications for API cost and cache hit rates.
This commit is contained in:
ControlNet
2026-02-20 02:31:18 +11:00
parent ca655a7deb
commit ddc2edfa0a
11 changed files with 321 additions and 10 deletions
@@ -76,6 +76,7 @@ export async function applyAgentConfig(params: {
const currentModel = params.config.model as string | undefined;
const disabledSkills = new Set<string>(params.pluginConfig.disabled_skills ?? []);
const useTaskSystem = params.pluginConfig.experimental?.task_system ?? false;
const disableOmoEnv = params.pluginConfig.experimental?.disable_omo_env ?? false;
const builtinAgents = await createBuiltinAgents(
migratedDisabledAgents,
@@ -90,6 +91,7 @@ export async function applyAgentConfig(params: {
currentModel,
disabledSkills,
useTaskSystem,
disableOmoEnv,
);
const includeClaudeAgents = params.pluginConfig.claude_code?.agents ?? true;
@@ -1275,3 +1275,65 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
})
})
describe("disable_omo_env pass-through", () => {
test("passes disable_omo_env=true to createBuiltinAgents", async () => {
//#given
const pluginConfig: OhMyOpenCodeConfig = {
experimental: { disable_omo_env: true },
}
const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6",
agent: {},
}
const handler = createConfigHandler({
ctx: { directory: "/tmp" },
pluginConfig,
modelCacheState: {
anthropicContext1MEnabled: false,
modelContextLimitsCache: new Map(),
},
})
//#when
await handler(config)
//#then
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
mock: { calls: unknown[][] }
}
const callArgs =
createBuiltinAgentsMock.mock.calls[createBuiltinAgentsMock.mock.calls.length - 1]
expect(callArgs).toBeDefined()
expect(callArgs?.[12]).toBe(true)
})
test("passes disable_omo_env=false when config field is omitted", async () => {
//#given
const pluginConfig: OhMyOpenCodeConfig = {}
const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6",
agent: {},
}
const handler = createConfigHandler({
ctx: { directory: "/tmp" },
pluginConfig,
modelCacheState: {
anthropicContext1MEnabled: false,
modelContextLimitsCache: new Map(),
},
})
//#when
await handler(config)
//#then
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
mock: { calls: unknown[][] }
}
const callArgs =
createBuiltinAgentsMock.mock.calls[createBuiltinAgentsMock.mock.calls.length - 1]
expect(callArgs).toBeDefined()
expect(callArgs?.[12]).toBe(false)
})
})