a2a-source-edit: write agent.py
This commit is contained in:
12
agent.py
12
agent.py
@@ -1032,14 +1032,10 @@ async def _persist_text(ctx: RunContext[NoAuth], run_id: str, filename: str, tex
|
||||
sha = hashlib.sha256(data).hexdigest()
|
||||
artifact_uri: str | None = None
|
||||
try:
|
||||
view = await ctx.workspace.open_view(
|
||||
purpose="persist revenue recovery output",
|
||||
hints=[rel_path],
|
||||
max_files=1,
|
||||
mode=WorkspaceMode.READ_WRITE_OVERLAY,
|
||||
reason="write generated output under outputs/revenue-recovery",
|
||||
)
|
||||
await view.write(rel_path, data)
|
||||
writer = getattr(ctx.workspace, "write_bytes", None)
|
||||
if writer is None:
|
||||
raise RuntimeError("workspace client does not expose direct output writes")
|
||||
writer(rel_path, data)
|
||||
except Exception as exc: # workspace may be unavailable in local smoke calls; artifact still persists.
|
||||
await ctx.emit_event(AgentEvent(kind="workspace_write_warning", payload={"path": rel_path, "message": str(exc)[:300]}))
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user