Design doc: conversation memory layer (#86)#98
Open
vahid-ahmadi wants to merge 1 commit into
Open
Conversation
Design-only proposal for persisting a structured active_scenario (household + reform + comparison baseline) across turns within a conversation, with get_scenario/update_scenario tools, server-side round-trip through the chat_conversations table, and an active-scenario pill in the chat input chrome. No implementation — for PR discussion. Refs #86 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Beta preview is ready.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Design doc (no implementation) for issue #86: persist a structured active scenario (household + reform + comparison baseline) across turns within a conversation, so follow-ups like "what if they were married?" mutate one field instead of forcing the agent to re-derive the whole household from scrollback. The doc is grounded in the current code — the streaming loop and prompt assembly in
backend/routes/chatbot.py, the tool dispatch/definitions inbackend/agent_tools.py, thechat_conversationspersistence inbackend/routes/conversations.py, and the input chrome infrontend/src/app/ChatPage.tsx— withfile:linereferences throughout. Taggedneeds-design; opening in PR form for discussion before any code.TL;DR of the recommended approach
active_scenarioper conversation, owned by the client and resent each turn — mirrors howmessagesalready round-trip (client-owns-state), so no second/racing DB writer.get_scenario/update_scenario(patch), added toTOOL_DEFINITIONS, but handled in the chat loop (not inexecute_tool) because they touch per-conversation state andexecute_toolis intentionally stateless.update_scenarioshallow-merges (household merged one level deeper)._build_system_blocks(same pattern as Plan/Charts directives) — the agent sees prior state for free and is robust to a missed write; static behavioural rules go in the cachedSYSTEM_PROMPT.active_scenarioTEXT column onchat_conversations, added via the existing idempotentensure_tableALTER pattern; round-trips through save/load/share and thedoneSSE event + chat request._build_compiled_policy/ typed-tool args so it slots into Register the three dormant typed tools (UK) #55/Add uk_python typed tools (run_economy_simulation) to fix B1 reform failures #97 once those land.Key open questions flagged for the team
reform/householdshape aligned with the typed-tool args; sequence this after/alongside them so the schema doesn't get redone.Refs #86
🤖 Generated with Claude Code