a2a-source-edit: write agent.py
This commit is contained in:
14
agent.py
14
agent.py
@@ -1032,12 +1032,14 @@ 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:
|
||||||
grant = await ctx.workspace.request_access(files=[rel_path], mode=WorkspaceMode.READ_WRITE_OVERLAY, reason="persist redacted revenue recovery output", purpose="write revenue recovery artifact")
|
view = await ctx.workspace.open_view(
|
||||||
view = await ctx.workspace.request_access(files=[rel_path], mode=WorkspaceMode.READ_WRITE_OVERLAY, reason="persist redacted revenue recovery output", purpose="write revenue recovery artifact")
|
purpose="persist revenue recovery output",
|
||||||
# The workspace API returns grants; open a view for concrete writes.
|
hints=[rel_path],
|
||||||
opened = 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")
|
max_files=1,
|
||||||
await opened.write(rel_path, data)
|
mode=WorkspaceMode.READ_WRITE_OVERLAY,
|
||||||
_ = grant, view
|
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