[Bug]: ListTasks prints unset fields on every task (history: [] with historyLength=0, empty mediaType/filename on parts)
Mantenedores costumam responder em até 2 dias
Avaliação
Esta issue ainda não foi avaliada.
Descrição
What happened?
ListTasks (JSON-RPC and REST) serializes its tasks differently from GetTask. serialize_list_tasks_response uses MessageToDict(..., always_print_fields_with_no_presence=True), which is there so nextPageToken, pageSize and totalSize are always present. But the flag applies to the whole tree, so every nested task, message and part also gets its unset fields printed as defaults:
Two visible effects on main (2ba8e7b):
- With
historyLength: 0, each task still carries"history": []. §3.2.4 says that for 0 "thehistoryfield SHOULD be omitted" (https://a2a-protocol.org/latest/specification/#324-history-length-semantics), andGetTaskdoes omit it. #1211 fixed the same thing forartifacts, by popping the key afterwards. - Messages and parts in a listed task get fields the stored task never had:
"filename": ""and"mediaType": ""on a text part,"contextId": "","taskId": "","extensions": []and"referenceTaskIds": []on a message. The same task fetched withGetTaskhas none of them, so one task has two JSON shapes depending on the method used to read it.
Repro (one stored task, real DefaultRequestHandler behind create_jsonrpc_routes):
import asyncio, json, httpx
from starlette.applications import Starlette
from a2a.server.context import ServerCallContext
from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.routes import create_jsonrpc_routes
from a2a.server.tasks import InMemoryTaskStore
from a2a.types.a2a_pb2 import AgentCard, Message, Part, Role, Task, TaskState, TaskStatus
async def main():
store = InMemoryTaskStore()
msg = Message(message_id='m1', role=Role.ROLE_USER, parts=[Part(text='hi')])
await store.save(Task(id='t1', context_id='c1', status=TaskStatus(state=TaskState.TASK_STATE_WORKING), history=[msg]), ServerCallContext())
handler = DefaultRequestHandler(None, store, AgentCard(name='a', version='1'))
app = Starlette(routes=create_jsonrpc_routes(handler, '/'))
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url='http://agent', headers={'A2A-Version': '1.0'}) as c:
async def call(method, params):
r = await c.post('/', json={'jsonrpc': '2.0', 'id': 1, 'method': method, 'params': params})
return r.json()['result']
print('GetTask historyLength=0:', json.dumps(await call('GetTask', {'id': 't1', 'historyLength': 0})))
print('ListTasks historyLength=0:', json.dumps((await call('ListTasks', {'historyLength': 0}))['tasks'][0]))
print('GetTask :', json.dumps((await call('GetTask', {'id': 't1'}))['history']))
print('ListTasks :', json.dumps((await call('ListTasks', {}))['tasks'][0]['history']))
asyncio.run(main())
Output on main:
GetTask historyLength=0: {"id": "t1", "contextId": "c1", "status": {"state": "TASK_STATE_WORKING"}}
ListTasks historyLength=0: {"id": "t1", "contextId": "c1", "status": {"state": "TASK_STATE_WORKING"}, "history": []}
GetTask : [{"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hi"}]}]
ListTasks : [{"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hi", "filename": "", "mediaType": ""}], "contextId": "", "taskId": "", "extensions": [], "referenceTaskIds": []}]
REST GET /tasks?historyLength=0 shows the same output, since both bindings use serialize_list_tasks_response.
Expected: each task in ListTasks serializes like the same task from GetTask: no history key for historyLength: 0, and no empty-default fields on messages and parts. Only the top-level response fields (tasks, nextPageToken, pageSize, totalSize) and, with includeArtifacts: true, artifacts need to be printed when empty.
Actual: history: [] with historyLength: 0, and empty-string or empty-list values on every nested message and part.
Happy to send a fix if that helps.
Code of Conduct
- I agree to follow this project's Code of Conduct
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 540
- Merge médio
- 2d 9h
- PRs com merge (30d)
- 56
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de a2aproject/a2a-python
-
[Bug]: `A2A-Version` validation ignores minor versions and the query parameterTalvez já em andamento @rohityan assumiu há 82 dias. Abertacomponent: server status:awaiting response status:stale
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
a2aproject/a2a-python#1204 · 4 comentários · 1 responsável ·
Mantenedores costumam responder em até 2 dias
-
[Bug]: REST task/request id sanitizationTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertamaintainers-only
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
a2aproject/a2a-python#805 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
[Bug]: JSON-RPC client ignores the JSON-RPC error body when the HTTP status is not 2xxTalvez já em andamento @rohityan assumiu hoje. Aberta
a2aproject/a2a-python#1475 · 2 responsáveis ·
Mantenedores costumam responder em até 2 dias
-
[Feat]: validate_input_modes: match media ranges such as image/* declared in the agent cardTalvez já em andamento @rohityan assumiu há 2 dias. Aberta
a2aproject/a2a-python#1468 · 2 responsáveis ·
Mantenedores costumam responder em até 2 dias
-
Required extensions aren't enforced, so ExtensionSupportRequiredError is never raisedTalvez já em andamento @rohityan assumiu há 2 dias. Abertacomponent: server status:awaiting response
a2aproject/a2a-python#1467 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 2 dias
Todas as issues de a2aproject/a2a-python
Issues semelhantes
-
area:security effort:S priority:P3 status:needs-triage type:chore
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
randomparity/kdive#3657 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
aws/mcp-proxy-for-aws#476 ·
Mantenedores costumam responder em até 1 dia
-
fix(cli): a --root that does not exist exits 0 with 'Scanned 0 file(s)', so a wrong path in CI passes silentlyTalvez já em andamento @arpanjot-coding assumiu hoje. Abertaarea: runtime automation bug cli code-scanning consistency developer-experience difficulty: easy github-actions good first issue help wanted json-output priority: P3 python sarif silent-failure static-analysis tests
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
ContainsOnly raises TypeError for unhashable input with set-based choicesTalvez já em andamento @prathamchoksi assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
marshmallow-code/marshmallow#3115 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia