From 03daa6ade04557fde344e7511877799ca5b59a26 Mon Sep 17 00:00:00 2001 From: a2a-cloud Date: Sat, 18 Jul 2026 09:13:48 +0000 Subject: [PATCH] a2a-source-edit: write agent.py --- agent.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/agent.py b/agent.py index 94720f9..ac941ce 100644 --- a/agent.py +++ b/agent.py @@ -5,6 +5,7 @@ bounded browser base64 bridge, managed Postgres persistence, and receipt rows. """ from __future__ import annotations +import asyncio import base64 import csv import hashlib @@ -94,7 +95,7 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]): "highest numeric value, persist the grounded answer in user-scoped " "managed Postgres, and reopen it from a polished one-page app." ) - version = "0.1.1" + version = "0.1.2" config_model = CsvAnswersStudioV1Config auth_model = PlatformUserAuth @@ -136,7 +137,8 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]): if not result.ok: return result try: - saved, receipt_id = _persist_analysis_and_receipt( + saved, receipt_id = await asyncio.to_thread( + _persist_analysis_and_receipt, tenant_key=tenant, analysis_id=analysis_id, question=question, @@ -220,7 +222,7 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]): ) -> CsvAnalysisResult: tenant = _tenant_key(ctx) try: - record = _load_analysis(tenant, analysis_id) + record = await asyncio.to_thread(_load_analysis, tenant, analysis_id) except Exception: # noqa: BLE001 return _error( analysis_id, @@ -245,7 +247,8 @@ class CsvAnswersStudioV1(A2AAgent[CsvAnswersStudioV1Config, PlatformUserAuth]): tenant = _tenant_key(ctx) safe_limit = min(max(int(limit), 1), 50) try: - return CsvAnalysisListResult(ok=True, analyses=_list_analyses(tenant, safe_limit)) + analyses = await asyncio.to_thread(_list_analyses, tenant, safe_limit) + return CsvAnalysisListResult(ok=True, analyses=analyses) except Exception: # noqa: BLE001 return CsvAnalysisListResult( ok=False,