MCPcopy Create free account
hub / github.com/vercel/examples / tool_completed_sse

Function tool_completed_sse

python/vibe-coding-ide/backend/src/sse.py:53–97  ·  view source on GitHub ↗
(
    task_id: str,
    ev: dict[str, Any],
    base_payload: dict[str, Any],
    project: dict[str, str],
)

Source from the content-addressed store, hash-verified

51
52
53def tool_completed_sse(
54 task_id: str,
55 ev: dict[str, Any],
56 base_payload: dict[str, Any],
57 project: dict[str, str],
58) -> str:
59 output_data: Any = ev.get("output_data")
60 if ev.get("name") == "request_code_execution" and isinstance(output_data, dict):
61 # Keep the store up-to-date with the latest project snapshot used by the agent
62 try:
63 # fire-and-forget update; ignore if running outside async loop
64 import asyncio
65
66 coro = update_run_project(task_id, project)
67 if asyncio.get_event_loop().is_running():
68 asyncio.create_task(coro)
69 else:
70 # fallback if called in sync context
71 asyncio.run(coro)
72 except Exception:
73 pass
74 # Issue a compact resume token that only carries the run id
75 output_data = {
76 **output_data,
77 "resume_token": make_stream_token({"run_id": task_id}),
78 }
79
80 return sse_format(
81 emit_event(
82 task_id,
83 "progress_update_tool_action_completed",
84 data={
85 "result": {
86 "tool_call": {
87 "id": ev["tool_id"],
88 "function": {
89 "name": ev["name"],
90 "arguments": ev.get("arguments"),
91 },
92 },
93 "output_data": output_data,
94 }
95 },
96 )
97 )

Callers 2

run_agent_flowFunction · 0.90
resume_agent_flowFunction · 0.90

Calls 5

update_run_projectFunction · 0.90
make_stream_tokenFunction · 0.90
sse_formatFunction · 0.85
emit_eventFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected