Repository navigation
Expand file tree
/
Copy pathl3_live_context.py
More file actions
48 lines (37 loc) · 1.55 KB
/
Copy pathl3_live_context.py
File metadata and controls
48 lines (37 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""L3 - Agent + live context.
Upgrades your agent with read-only SQL tools from an MCP server and opens a
conversation. Ask, run `python inject.py` in a second terminal, then ask again:
the answer changes.
python l3_live_context.py
"""
from common import (
agent_params,
chat,
ensure_agent,
ensure_environment,
load_config,
load_layer,
mcp_vault_ids,
open_session,
orca_client,
run_main,
state_for,
)
QUESTION = "Which accounts look like an account takeover right now?"
def main() -> None:
config = load_config(["ORCA_BASE_URL", "ORCA_MODEL"])
client = orca_client(config)
state = state_for(config)
environment_id = ensure_environment(client, state, f"hello-env-{config.participant}")
# The same agent, next version: agent/<stack>/l3-live-context.json adds the MCP server.
layer = load_layer("l3-live-context", config.stack)
agent = ensure_agent(client, state, agent_params(layer, config))
print(f"{agent.name} v{agent.version}: {layer['summary']}")
# StreamNative Cloud's MCP server needs a credential. It goes in a vault, never
# in the prompt. The MCP server on your laptop takes none, so there is no vault.
vault_ids = mcp_vault_ids(client, state, config)
session = open_session(client, state, environment_id, agent, "L3: live context", vault_ids=vault_ids)
print("Tip: after the first answer, run `python inject.py` in another terminal and ask again.\n")
chat(client, session.id, QUESTION, send_first=config.stack == "local")
if __name__ == "__main__":
run_main(main)