Loading…
Loading…
Features · Connect · Sessions and memory
A session is a conversation that continues: each run sees what came before. Give the agent a session store and a session id, and the history is saved after every turn and loaded before the next, even by a new process.
from shipit_agent import Agent, FileSessionStorefrom shipit_agent.llms import build_llm_from_envstore = FileSessionStore(".shipit/sessions")agent = Agent.with_builtins(llm=build_llm_from_env(), session_store=store, session_id="ticket-812")agent.run("The nightly export fails with a timeout. Find out why.")agent.run("Now fix it and add a test.") # sees the first turn
Run 1
session_id=ticket-812
Session store
file, memory or yours
Run 2
loads the history
Memory tool
facts across sessions
The code is a checked example from the docs; the output is an example of what it prints.
from shipit_agent import Agent, FileSessionStore
from shipit_agent.llms import build_llm_from_env
store = FileSessionStore(".shipit/sessions")
agent = Agent.with_builtins(llm=build_llm_from_env(), session_store=store, session_id="ticket-812")
agent.run("The nightly export fails with a timeout. Find out why.")
agent.run("Now fix it and add a test.") # sees the first turn6 more ways to use it
Each example is from the docs and checked against the library.
chat = agent.chat_session(session_id="support-42")
chat.send("The export button does nothing on Safari.")
reply = chat.send("It started after Tuesday's release.")
print(reply.output)
for event in chat.stream("Which commit changed the export code?"):
print(event.type, event.message)Stores
In memory, on disk, or your own class with load, save and list_all.
Managing sessions
List, fork and rename sessions.
Memory
The memory tool saves facts to a memory store and searches them later.
Token caps
max_session_tokens stops a session once its runs together reach a limit.
| Parameter | Default | What it does |
|---|---|---|
| session_store | None | Where conversations are saved between runs. Sessions. |
| session_id | None | The conversation to continue. |
| memory_store | None | Where the `memory` tool saves facts. Memory. |
| history | empty | Messages to start the conversation with. |
| max_session_tokens | None | Soft stop across every run of this agent (or one chat session), checked between steps. Clones start fresh; reset with reset_session_usage(). |