Loading the notebook…
Loading the notebook…
Notebooks · First agents · 03
This notebook shows both ways to preserve context:
Its imports and arguments are checked against shipit-agent 3.0. The outputs were saved when it was written, for an earlier release.
from pathlib import Path
import sys
from IPython.display import Markdown, display
ROOT = (
Path.cwd().resolve().parent
if Path.cwd().name == "notebooks"
else Path.cwd().resolve()
)
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from examples.run_multi_tool_agent import build_llm_from_env
from shipit_agent import Agent, FileSessionStore, Messagellm = build_llm_from_env("bedrock")
seeded_agent = Agent(
llm=llm,
history=[
Message(role="user", content="We are building an internal project assistant."),
Message(
role="assistant",
content="Understood. I will keep answers focused on developer workflows.",
),
],
)
seeded_result = seeded_agent.run("What prior context do you have?")
display(Markdown(f"**Seeded Agent Response:** {seeded_result.output}"))Seeded Agent Response: I don’t retain any memory between separate conversations, so the only context I have right now is what’s been exchanged in this session:
Beyond that, I have no additional background (e.g., your organization’s architecture, the technologies you’re using, specific requirements, or any previous discussions). If you’d like me to take previous design notes, constraints, or goals into account, just paste or summarize them here and I’ll incorporate them into my responses.
session_store = FileSessionStore(ROOT / ".shipit_notebooks" / "sessions_demo")
session_agent = Agent(
llm=llm,
session_store=session_store,
session_id="demo-chat",
)
session_agent.run("My project codename is Atlas.")
follow_up = session_agent.run("What project codename did I mention earlier?")
display(Markdown(f"**Follow-up Response:** {follow_up.output}"))Follow-up Response: You said the project codename is Atlas.
chat_session = session_agent.chat_session(session_id="demo-chat")
chat_session.history()[Message(role='system', content="You are Shipit, a capable general-purpose agent runtime.\n\nCore behavior:\n- Be accurate, direct, and execution-oriented.\n- Solve the user's task end-to-end when possible instead of stopping at analysis.\n- Use tools when they materially improve correctness, freshness, or efficiency.\n- Prefer structured evidence over guesses.\n\nTool behavior:\n- Read tool descriptions and tool prompts carefully before calling them.\n- Use the smallest correct tool for the job.\n- When a task is complex, plan before acting.\n- When information may be outdated, prefer web and… (447 more characters)
Message(role='user', content='My project codename is Atlas.', name=None, metadata={}),
Message(role='assistant', content='Got it—your project’s codename is **Atlas**. How can I assist you with Atlas today?', name=None, metadata={'model': 'bedrock/openai.gpt-oss-120b-1:0', 'provider': 'litellm'}),
Message(role='system', content="You are Shipit, a capable general-purpose agent runtime.\n\nCore behavior:\n- Be accurate, direct, and execution-oriented.\n- Solve the user's task end-to-end when possible instead of stopping at analysis.\n- Use tools when they materially improve correctness, freshness, or efficiency.\n- Prefer structured evidence over guesses.\n\nTool behavior:\n- Read tool descriptions and tool prompts carefully before calling them.\n- Use the smallest correct tool for the job.\n- When a task is complex, plan before acting.\n- When information may be outdated, prefer web and… (447 more characters)
Message(role='user', content='What project codename did I mention earlier?', name=None, metadata={}),
Message(role='assistant', content='You said the project codename is **Atlas**.', name=None, metadata={'model': 'bedrock/openai.gpt-oss-120b-1:0', 'provider': 'litellm'})]