The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): --max-turns reaches the gateway as an integer
teknium1028e8ff337f5
diff --git a/ui-tui/src/__tests__/canonicalGateway.test.ts b/ui-tui/src/__tests__/canonicalGateway.test.tsindex 42a4f248563..0bdd11c6e01 100644--- a/ui-tui/src/__tests__/canonicalGateway.test.ts+++ b/ui-tui/src/__tests__/canonicalGateway.test.ts@@ -1,6 +1,6 @@import { expect, it } from 'vitest'-import { canonicalRequest, canonicalResult, sharedControlParams } from '../canonicalGateway.js'+import { canonicalRequest, canonicalResult, localCreationOptions, sharedControlParams } from '../canonicalGateway.js'it('retains prepared identity and rejects unsupported TUI launch policy instead of impersonating CLI', () => {const contract = { sources: ['tui'], parameters: ['request_id', 'source', 'model', 'cwd', 'toolsets'] }@@ -12,3 +12,9 @@ it('retains prepared identity and rejects unsupported TUI launch policy insteadconst receipt = canonicalResult('prompt.submit', { admission_id: 'server-admission', ref: { profile_id: '/tmp/profile', session_id: 'sid' }, status: 'queued' }, { input_id: 'prepared-id' })expect(receipt).toMatchObject({ admission_id: 'server-admission', input_id: 'prepared-id', target_profile_home: '/tmp/profile', target_session_id: 'sid' })})++it('rebuilds --max-turns from the launcher environment as the integer the session policy requires', () => {+ const options = localCreationOptions({ HERMES_TUI_MAX_TURNS: '5', HERMES_MODEL: 'local-model' } as NodeJS.ProcessEnv)+ expect(options.max_turns).toBe(5)+ expect(localCreationOptions({} as NodeJS.ProcessEnv)).not.toHaveProperty('max_turns')+})diff --git a/ui-tui/src/canonicalGateway.ts b/ui-tui/src/canonicalGateway.tsindex 02d8f0d0217..81d72bba457 100644--- a/ui-tui/src/canonicalGateway.ts+++ b/ui-tui/src/canonicalGateway.ts@@ -79,12 +79,16 @@ export function localCreationOptions(env = process.env): Record<string, unknown>const fields: Record<string, string | undefined> = {model: env.HERMES_MODEL, provider: env.HERMES_TUI_PROVIDER, cwd: env.HERMES_CWD,skills: env.HERMES_TUI_SKILLS, checkpoints: env.HERMES_TUI_CHECKPOINTS,- max_turns: env.HERMES_TUI_MAX_TURNS, accept_hooks: env.HERMES_ACCEPT_HOOKS+ accept_hooks: env.HERMES_ACCEPT_HOOKS}const options: Record<string, unknown> = Object.fromEntries(Object.entries(fields).filter(([, value]) => value))if (env.HERMES_TUI_TOOLSETS) { options.toolsets = env.HERMES_TUI_TOOLSETS.split(',') }+ // The launcher exports `--max-turns 5` as the string "5"; the policy+ // requires an int, so the environment's text form is undone here.+ if (env.HERMES_TUI_MAX_TURNS) { options.max_turns = Number(env.HERMES_TUI_MAX_TURNS) }+return options}