trading_agent.memory.session_keeper
¶
Starts, resumes and rolls over a desk's sessions.
When the desk starts, the keeper asks the model router to pick up the session saved before a restart. Before each turn it checks the India date: on the first turn of a new day it asks the desk to summarise the old session and fold the day's notes into Memory.md, saves that summary, and starts a fresh session. The first message of every new session carries the most recent summary, so the desk knows what happened last.
Typical usage example:
keeper = SessionKeeper('main', router, store, event_bus) await keeper.start() trigger = await keeper.prepare(trigger)
SessionKeeper
¶
Looks after one desk's sessions.
Creates the keeper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk. |
required |
router
|
ModelRouter
|
The desk's router, built with the same store. |
required |
store
|
SessionStore
|
The desk's sessions folder. |
required |
event_bus
|
EventBus
|
Where new sessions are announced. |
required |
curator
|
SkillCurator | None
|
Reviews the desk's own skills after the day's summary, or None to skip the review. |
None
|
Source code in src/trading_agent/memory/session_keeper.py
start
async
¶
Picks up the saved session, or starts the first one, when the desk starts.
Source code in src/trading_agent/memory/session_keeper.py
prepare
async
¶
Rolls over to a new session on a new day, and seeds a new session's first message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger
|
Trigger
|
The trigger about to run. |
required |
Returns:
| Type | Description |
|---|---|
Trigger
|
The trigger, with the previous session's summary in front when the session is new. |
Source code in src/trading_agent/memory/session_keeper.py
roll_over
async
¶
Ends the current session with a summary and starts a fresh one for today.
Returns:
| Type | Description |
|---|---|
str | None
|
The new session's identifier. |