You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 75df7a5
Browse filesBrowse the repository at this point in the historyBrowse files
A lightweight structural manifest injected into the system prompt (~300-500 tokens). Gives the LLM enough context to formulate targeted tool calls:
125
+
A lightweight structural manifest injected into the system prompt (~300-500 tokens). Gives the LLM enough context to formulate targeted tool calls. Built from a single `getTuple()` call on the latest runtime checkpoint — no history iteration. The agent fetches action history on demand via retrieval tools.
All tools are closures over the session's store — simple key lookups, no LLM intermediary.
138
+
All tools read from the **runtime graph's checkpoints** via the session's `SqliteSaver`/`PostgresSaver`. They are closures over the checkpointer and sessionId — simple checkpoint lookups, no LLM intermediary.
138
139
139
140
| Tool | Input | Returns |
140
141
|---|---|---|
141
142
|`getGameSpec`| none | Full game specification text |
142
143
|`getArtifact`|`{ type: 'schema' \| 'transitions' \| 'instructions', id?: string }`| Full artifact or specific fragment by ID |
|`getStateAtStep`|`{ step: number }`| Game + player state snapshot from checkpoint |
145
-
|`getTransitionRationale`|`{ transitionId: string, step?: number }`| The LLM executor's reasoning for a specific state change |
146
-
|`getActionLog`|`{ playerId?: string, fromStep?: number, toStep?: number }`| Filtered action history |
145
+
|`getRecentStates`|`{ count?: number }`| Last N game + player state snapshots from checkpoint history (default 5). Each entry includes phase, gameState, and the action that triggered it. The assistant can call again with a larger count to look further back. |
146
+
|`getActionLog`|`{ playerId?: string, lastN?: number }`| Filtered action history from recent checkpoints |
147
147
148
148
### What the LLM Does NOT See by Default
149
149
@@ -162,10 +162,8 @@ This keeps the base prompt small and the LLM in control of what context it needs
162
162
Creator: "Player 2 won the round even though both chose rock"
@@ -223,35 +221,39 @@ const result = await artifactEditorGraph.invoke({
223
221
});
224
222
```
225
223
226
-
The `repairArtifacts` tool wraps this: it gathers current artifacts from the store, adds the formulated error, and calls the editor graph.
224
+
The `repairArtifacts` tool wraps this: it loads current artifacts from the **runtime graph's latest checkpoint**, adds the formulated error, and calls the editor graph.
227
225
228
226
## Conversation State
229
227
230
-
### V1: Ephemeral
231
-
232
-
Message history is held in-memory for the duration of the session. Stored as a `BaseMessage[]` array in the graph state, following the standard LangGraph chat pattern.
228
+
Follows the same pattern as the design conversation (`src/ai/design/`):
233
229
234
-
The sim assistant graph state:
230
+
1.**LangGraph checkpointer**: Graph compiled with `SqliteSaver` or `PostgresSaver` (via `getSaver(sessionId, 'sim-assistant')`). Messages accumulate in checkpoints across invocations automatically.
231
+
2.**GraphCache**: Compiled graph instances cached in an LRU `GraphCache` keyed by `sessionId`. Cache eviction doesn't lose state — checkpointed data persists in the database.
232
+
3.**thread_id = sessionId**: Each `graph.stream()` call passes `{ configurable: { thread_id: sessionId } }`. The checkpointer loads prior messages, the reducer appends the new message.
233
+
4.**Messages reducer**: Appends new messages, filters system messages, caps at a reasonable limit.
// Session context (set once at graph creation, read-only)
242
246
sessionId: Annotation<string>(),
243
247
gameId: Annotation<string>(),
244
248
245
-
// Manifest (rebuilt before each invocation from store)
249
+
// Manifest (rebuilt before each invocation from runtime checkpoint)
246
250
manifest: Annotation<string>(),
247
251
});
248
252
```
249
253
250
-
Conversation history is lost when the session ends. Changes made via the repair tool persist in the store.
254
+
### Future: Persistent across page refreshes
251
255
252
-
### Future: Persistent
253
-
254
-
Store-backed message history, loadable across sessions. Enables "pick up where we left off" after page refresh.
256
+
V1 conversation survives as long as the checkpointer's backing store is alive (SQLite file or Postgres rows). A future enhancement would add explicit session resume from the frontend after page refresh, loading the last checkpoint for the thread.
255
257
256
258
## Published Artifact Guard
257
259
@@ -281,16 +283,19 @@ The sim assistant surfaces this to the creator and offers to summarize the neede
12.**AssistantContext** — Replace stub `sendAssistantMessage()` with real API call + SSE streaming. Map SSE events to `AssistantMessage[]` state. Handle `repair:started/progress/completed` as system messages in the chat.
0 commit comments