a2a-source-edit: write agent.py
This commit is contained in:
14
agent.py
14
agent.py
@@ -166,13 +166,17 @@ class ProductionProofV116HighUtili72552(
|
||||
)
|
||||
|
||||
queue = [_triage_message(message, policy) for message in messages]
|
||||
queue.sort(key=lambda item: _priority_rank(item.priority))
|
||||
queue.sort(key=lambda queue_entry: _priority_rank(queue_entry.priority))
|
||||
urgent_count = 0
|
||||
for queue_entry in queue:
|
||||
if queue_entry.priority == "urgent":
|
||||
urgent_count += 1
|
||||
summary = _summary(queue)
|
||||
report = {
|
||||
"generated_at": datetime.now(UTC).isoformat(),
|
||||
"summary": summary,
|
||||
"approval_boundary": _approval_boundary(),
|
||||
"queue": [item.model_dump(mode="json") for item in queue],
|
||||
"queue": [queue_entry.model_dump(mode="json") for queue_entry in queue],
|
||||
}
|
||||
report_bytes = json.dumps(report, indent=2, ensure_ascii=False).encode("utf-8")
|
||||
artifact = await ctx.write_artifact(
|
||||
@@ -194,7 +198,7 @@ class ProductionProofV116HighUtili72552(
|
||||
input_hash=input_hash,
|
||||
result_summary={
|
||||
"message_count": len(queue),
|
||||
"urgent_count": sum(1 for item in queue if item.priority == "urgent"),
|
||||
"urgent_count": urgent_count,
|
||||
"artifact_name": artifact.name,
|
||||
},
|
||||
)
|
||||
@@ -522,8 +526,8 @@ def _priority_rank(priority: str) -> int:
|
||||
|
||||
def _summary(queue: list[QueueItem]) -> str:
|
||||
counts: dict[str, int] = {}
|
||||
for item in queue:
|
||||
counts[item.priority] = counts.get(item.priority, 0) + 1
|
||||
for queue_entry in queue:
|
||||
counts[queue_entry.priority] = counts.get(queue_entry.priority, 0) + 1
|
||||
parts = [f"{counts.get(name, 0)} {name}" for name in ["urgent", "high", "normal", "low"] if counts.get(name, 0)]
|
||||
return f"Prioritized {len(queue)} people-inbox message(s): " + ", ".join(parts) + "."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user