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()
|
sha = hashlib.sha256(data).hexdigest()
|
||||||
artifact_uri: str | None = None
|
artifact_uri: str | None = None
|
||||||
try:
|
try:
|
||||||
view = await ctx.workspace.open_view(
|
writer = getattr(ctx.workspace, "write_bytes", None)
|
||||||
purpose="persist revenue recovery output",
|
if writer is None:
|
||||||
hints=[rel_path],
|
raise RuntimeError("workspace client does not expose direct output writes")
|
||||||
max_files=1,
|
writer(rel_path, data)
|
||||||
mode=WorkspaceMode.READ_WRITE_OVERLAY,
|
|
||||||
reason="write generated output under outputs/revenue-recovery",
|
|
||||||
)
|
|
||||||
await view.write(rel_path, data)
|
|
||||||
except Exception as exc: # workspace may be unavailable in local smoke calls; artifact still persists.
|
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]}))
|
await ctx.emit_event(AgentEvent(kind="workspace_write_warning", payload={"path": rel_path, "message": str(exc)[:300]}))
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user