Skip to content

client_call_to_artifact

autogen.beta.a2a.mappers.events.client_call_to_artifact #

client_call_to_artifact(event, *, task_id, context_id, name=None, description=None, artifact_metadata=None, update_metadata=None)

Map a pending client-side tool invocation to a tool-call artifact.

Each call gets a fresh artifact keyed by the call id with last_chunk=True — a tool-call payload is delivered atomically, not streamed in chunks. name defaults to the tool name so downstream consumers can filter by it without decoding the payload.

Source code in autogen/beta/a2a/mappers/events.py
def client_call_to_artifact(
    event: ClientToolCallEvent,
    *,
    task_id: str,
    context_id: str,
    name: str | None = None,
    description: str | None = None,
    artifact_metadata: Mapping[str, Any] | None = None,
    update_metadata: Mapping[str, Any] | None = None,
) -> A2AToolCallArtifact:
    """Map a pending client-side tool invocation to a tool-call artifact.

    Each call gets a fresh artifact keyed by the call id with
    ``last_chunk=True`` — a tool-call payload is delivered atomically,
    not streamed in chunks. ``name`` defaults to the tool name so
    downstream consumers can filter by it without decoding the payload.
    """
    call = ToolCallEvent(id=event.id, name=event.name, arguments=event.arguments)
    artifact = _build_artifact(
        artifact_id=event.id,
        parts=[data_part(call_to_payload(call), media_type=MIME_TOOL_CALL)],
        name=name if name is not None else event.name,
        description=description,
        artifact_metadata=artifact_metadata,
    )
    update = _build_artifact_update(
        task_id=task_id,
        context_id=context_id,
        artifact=artifact,
        append=False,
        last_chunk=True,
        update_metadata=update_metadata,
    )
    return A2AToolCallArtifact(
        update=update,
        append=False,
        last_chunk=True,
        call=call,
    )