Skip to content

feat(cpp): runtime configuration and dynamic reconfiguration#531

Open
itomek wants to merge 2 commits intomainfrom
361-c-framework-runtime-configuration-and-dynamic-reconfiguration
Open

feat(cpp): runtime configuration and dynamic reconfiguration#531
itomek wants to merge 2 commits intomainfrom
361-c-framework-runtime-configuration-and-dynamic-reconfiguration

Conversation

@itomek
Copy link
Collaborator

@itomek itomek commented Mar 16, 2026

Summary

  • AgentConfig serialization: fromJson(), fromJsonFile(), toJson() via new src/types.cpp; validation covers empty strings, numeric bounds, temperature range, and maxConsecutiveRepeats >= 2
  • New fields wired: maxTokens (was hardcoded to 4096), maxPlanIterations, maxConsecutiveRepeats now read from config throughout the execution loop
  • Environment variable overrides: GAIA_BASE_URL, GAIA_MODEL_ID, GAIA_MAX_STEPS, GAIA_MAX_TOKENS, GAIA_CONTEXT_SIZE; deprecated aliases GAIA_CPP_BASE_URL/GAIA_CPP_CTX_SIZE emit stderr warnings
  • Dynamic reconfiguration: setModel(), setConfig(), setMaxSteps(), setMaxTokens(), setTemperature(), setDebug(), config() accessor — all thread-safe via configMutex_
  • Tool enable/disable: ToolInfo::enabled flag with setEnabled()/isEnabled()/enabledTools() on ToolRegistry; disabled tools hidden from LLM prompt and rejected on execute; rebuildSystemPrompt() flushes the cache
  • Thread safety: config snapshot at processQuery() start; double-checked locking in systemPrompt(); modelEnsured_ as std::atomic<bool>; config_.debug read under lock in MCP connection methods

Test plan

  • 77/77 unit tests pass
  • Lint clean

Closes #361
Also closes #394 and #395

itomek and others added 2 commits March 16, 2026 12:31
- Add AgentConfig serialization: fromJson(), fromJsonFile(), toJson() in new src/types.cpp
- Add AgentConfig validation with checks for empty strings, numeric bounds, temperature range
- Add maxTokens field to AgentConfig (was hardcoded to 4096 in agent.cpp)
- Wire maxTokens, maxPlanIterations, maxConsecutiveRepeats from config into processQuery loop
- Add environment variable overrides: GAIA_BASE_URL, GAIA_MODEL_ID, GAIA_MAX_STEPS, GAIA_MAX_TOKENS, GAIA_CONTEXT_SIZE; deprecation warnings for GAIA_CPP_BASE_URL and GAIA_CPP_CTX_SIZE
- Add dynamic reconfiguration setters: setModel(), setConfig(), setMaxSteps(), setMaxTokens(), setTemperature(), setDebug() and config() accessor
- Thread-safe config snapshot pattern in processQuery(); double-checked locking in systemPrompt(); modelEnsured_ as std::atomic<bool>
- Add ToolInfo::enabled flag with setEnabled()/isEnabled()/enabledTools() on ToolRegistry; disabled tools hidden from formatForPrompt() and rejected in executeTool()
- Add rebuildSystemPrompt() to flush cached system prompt after tool enable/disable changes
- Add 77 unit tests covering all new functionality

Closes #361, #394, #395

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ction edge case

- Snapshot config_.debug under configMutex_ in connectMcpServer() and
  reconnectMcpServer() — previously read without the lock, which was a
  data race if setDebug()/setConfig() was called concurrently
- Tighten maxConsecutiveRepeats validation to >= 2 (was > 0); a value
  of 1 produced repeatThreshold = 0, causing the loop-detection window
  to be zero-length and the agent to abort on the very first tool call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@itomek itomek linked an issue Mar 16, 2026 that may be closed by this pull request
@github-actions github-actions bot added the cpp label Mar 16, 2026
@itomek itomek self-assigned this Mar 16, 2026
@itomek itomek changed the base branch from main to kalin/chat-ui March 17, 2026 00:01
@itomek itomek changed the base branch from kalin/chat-ui to main March 17, 2026 00:13
@itomek itomek marked this pull request as ready for review March 18, 2026 17:14
@itomek itomek requested a review from kovtcharov-amd as a code owner March 18, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++ Framework: Wire up maxConsecutiveRepeats config field C++ Framework: Runtime configuration and dynamic reconfiguration

1 participant