Skip to content

v0.6.1

@hudhaifas hudhaifas tagged this 05 Jun 02:25
Add @dynamic_prompt middleware to build_agent_graph so the system
prompt is rebuilt on every turn instead of frozen at session start.
Without this, the model sees a stale snapshot — wrong date later in
a long session, and stale entity state if the entity is edited
mid-conversation.

prepare_agent_session now passes only static instructions to
build_agent_graph plus the agent reference; the dynamic suffix is
recomputed per turn from agent.get_dynamic_context().

Caching still works: AnthropicPromptCachingMiddleware runs after
inject_fresh_context, so Anthropic caches the static prefix and
treats the dynamic suffix as uncached.

Failure mode: if get_dynamic_context() throws, the wrapper logs and
falls back to empty string. Chat continues with stale context, not
broken.

langchain.agents.middleware.dynamic_prompt is a langchain 1.x
feature, so bump the dependency floor langchain>=1.0.
Assets 2
Loading