[Bug]: Executor failure right after its Task is enqueued leaves the task SUBMITTED on DatabaseTaskStore
Los mantenedores suelen responder en 2 días
@rohityan ya está trabajando en esto.
Desde el 18/10/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Follow-up to #1067, on a path #1106 did not cover.
What happened?
With DatabaseTaskStore, if an executor enqueues its Task and raises before that Task is saved, the failure write that #1106 added to _run_producer races the consumer's save of the Task. Both insert the same row and one of them fails:
- If the producer's insert fails, the error never reaches the consumer.
on_message_sendreturns the task asSUBMITTED, and the row staysSUBMITTED. - If the consumer's insert fails,
on_message_sendraisesIntegrityErrorinstead of the executor's error, and the stored task is the fallback, without the agent's metadata.
The window is about one store write, so it hits fast failures such as a refused connection, missing credentials or input validation, not failures after a model call. InMemoryTaskStore is not affected because its save never yields. Same on v1.2.2.
Reproduction
repro.py
import asyncio
import collections
import tempfile
import uuid
from sqlalchemy.ext.asyncio import create_async_engine
from a2a.helpers.proto_helpers import new_task_from_user_message
from a2a.server.agent_execution import AgentExecutor
from a2a.server.context import ServerCallContext
from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.tasks.database_task_store import DatabaseTaskStore
from a2a.types.a2a_pb2 import AgentCard, Message, Part, Role, SendMessageRequest, TaskState
class FailsAfterCreatingTask(AgentExecutor):
async def execute(self, context, event_queue):
task = new_task_from_user_message(context.message)
task.metadata.update({'agent_key': 'kept'})
self.task_id = task.id
await event_queue.enqueue_event(task)
raise RuntimeError('model call failed')
async def cancel(self, context, event_queue):
pass
async def main():
engine = create_async_engine(f'sqlite+aiosqlite:///{tempfile.mkdtemp()}/tasks.db')
store = DatabaseTaskStore(engine)
executor = FailsAfterCreatingTask()
handler = DefaultRequestHandler(executor, store, AgentCard(name='repro'))
outcomes = collections.Counter()
for _ in range(50):
message = Message(role=Role.ROLE_USER, message_id=str(uuid.uuid4()), parts=[Part(text='hi')])
context = ServerCallContext()
try:
result = await handler.on_message_send(SendMessageRequest(message=message), context)
client = f'returned {TaskState.Name(result.status.state)}'
except Exception as exc:
client = f'raised {type(exc).__name__}'
await asyncio.sleep(0.1)
stored = await store.get(executor.task_id, context)
kept = 'agent_key' in stored.metadata
outcomes[(client, TaskState.Name(stored.status.state), kept)] += 1
for (client, state, kept), n in outcomes.most_common():
print(f'{n:3} {client:30} stored {state:21} metadata kept: {kept}')
asyncio.run(main())
On main (01da00b), none of the 50 runs ends with the executor's error and a FAILED task:
30 returned TASK_STATE_SUBMITTED stored TASK_STATE_SUBMITTED metadata kept: True
19 raised IntegrityError stored TASK_STATE_FAILED metadata kept: False
1 raised RuntimeError stored TASK_STATE_FAILED metadata kept: False
Proposed fix
Make the consumer the only writer. The producer enqueues the failure instead of writing it, and the consumer writes FAILED after the events the executor enqueued before raising, creating the fallback task only if the executor never made one. An upsert in DatabaseTaskStore.save fixes the state but lets the fallback overwrite the agent's Task, and a lock still drops the agent's Task when the producer gets there first.
I have the change with a regression test that fails on main and passes with it, and can open a PR.
Environment
a2a-sdk main @ 01da00b and v1.2.2, Python 3.12, SQLAlchemy 2.1.5, aiosqlite 0.22.1, Linux.
- Lenguaje dominante
- Python
- Estrellas
- 2.2k
- Forks
- 511
- Merge medio
- 3 d 10 h
- PR fusionados (30 d)
- 47
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de a2aproject/a2a-python
-
[Bug]: REST task/request id sanitizationPosiblemente ocupada @Linux2010 la tomó hace 113 días. Abiertomaintainers-only
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
a2aproject/a2a-python#805 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[Bug]: Closing one client from a ClientFactory closes the shared httpx client for every other clientPosiblemente ocupada @rohityan la tomó hace 2 días. Abierto
a2aproject/a2a-python#1349 · 2 asignados ·
Los mantenedores suelen responder en 2 días
-
[Bug]: A2A exceptions lost their structured __repr__ after the client error refactor (#761)Posiblemente ocupada @rohityan la tomó hace 2 días. Abierto
a2aproject/a2a-python#1347 · 2 asignados ·
Los mantenedores suelen responder en 2 días
-
[Bug]: `A2A-Version` sent as a request parameter is ignored (spec §3.6.1), so a v1.0 request is treated as 0.3Posiblemente ocupada @rohityan la tomó hace 2 días. Abierto
a2aproject/a2a-python#1344 · 2 asignados ·
Los mantenedores suelen responder en 2 días
-
[Bug]: Client transports reject responses with unrecognized fields (spec 5.7)Posiblemente ocupada @rohityan la tomó hace 4 días. Abierto
a2aproject/a2a-python#1341 · 1 comentario · 2 asignados ·
Los mantenedores suelen responder en 2 días
Todos los issues de a2aproject/a2a-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SwiftKickMobile/skai#84 ·
-
Lychee link check failedAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jxxghp/MoviePilot#7070 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
flop-labs/technocore-chat#997 ·
Los mantenedores suelen responder en 1 día
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoopAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
doronz88/pymobiledevice3#2051 ·
Los mantenedores suelen responder en 1 día