Skip to content

Fix agent model cache identity#142

Merged
dubh3124 merged 1 commit into
release/v0.11.0from
codex/fix-agent-model-cache-identity
Jul 9, 2026
Merged

Fix agent model cache identity#142
dubh3124 merged 1 commit into
release/v0.11.0from
codex/fix-agent-model-cache-identity

Conversation

@dubh3124

@dubh3124 dubh3124 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a runtime cache bug where agent-level model overrides could reuse a stale compiled Deep Agents graph.

Root Cause

_model_cache_key() collapsed plain string model IDs to str, so different string IDs such as us.amazon.nova-lite-v1:0 and global.anthropic.claude-sonnet-5 could share the same graph cache entry. The cache also lacked a resolved provider/config identity, leaving same-model/different-provider or same-model/different-base-url cases vulnerable to stale graph reuse.

Changes

  • Include string model IDs in _model_cache_key().
  • Add a secret-free resolved model cache identity including provider, model ID, base URL, Bedrock region/role, generation settings, retries, and timeout.
  • Pass that identity from model resolution through DeepAgentStreamingService into CognitionAgentParams / RuntimeContext.
  • Preserve legacy resolve_model_for_session() tuple behavior while adding richer resolve_runtime_model_for_session() metadata.
  • Add regression tests for string model IDs, same-model/provider-config changes, resolver identity, and service pass-through.
  • Record both bug-fix entries in ROADMAP.md.

Validation

  • PYTHONPATH=. uv run pytest tests/unit/test_pluggability.py tests/unit/test_provider_resolution.py tests/unit/test_agent_def_field_wiring.py -q passed, 45 tests
  • PYTHONPATH=. uv run pytest tests/unit -q passed, 797 passed, 4 skipped
  • uv run ruff check . passed
  • PYTHONPATH=. uv run mypy server/app/agent/cognition_agent.py server/app/agent/resolver.py server/app/llm/deep_agent_service.py --ignore-missing-imports passed

@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cognition Ready Ready Preview, Comment Jul 9, 2026 1:35am

Request Review

@dubh3124 dubh3124 force-pushed the codex/fix-agent-model-cache-identity branch from d26d04b to 244dc6f Compare July 9, 2026 01:33
@dubh3124 dubh3124 changed the base branch from release/v0.10.4 to release/v0.11.0 July 9, 2026 01:33
@dubh3124 dubh3124 force-pushed the codex/fix-agent-model-cache-identity branch from 244dc6f to 73e7064 Compare July 9, 2026 01:35
@dubh3124 dubh3124 merged commit a1fcb9e into release/v0.11.0 Jul 9, 2026
11 checks passed
@dubh3124 dubh3124 deleted the codex/fix-agent-model-cache-identity branch July 9, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant