Skip to content

fix(server-common): refuse artifact updates on a task in a final state (no artifact persisted on, or handed over for, a final task) - #1392

Open
joulook wants to merge 1 commit into
a2aproject:mainfrom
joulook:fix/no-artifact-on-final-task
Open

joulook wants to merge 1 commit into
a2aproject:mainfrom
joulook:fix/no-artifact-on-final-task

Conversation

@joulook

@joulook joulook commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #1391.

TaskManager.saveTaskEvent(TaskArtifactUpdateEvent, ...) now refuses an artifact for a task whose state is final,
with the same A2AServerException/InternalError as validateStateTransition uses for a status change. The event
bus processor then distributes the error and pushes nothing (MainEventBusProcessor.java:309-318, 324). An agent that
keeps running after its task was canceled can no longer add an artifact to the CANCELED task or have one handed to the
push sender for it. An artifact handed over before the cancel can still be POSTed after it (see Scope).

Behaviour change: an artifact update for a completed/failed/canceled task now fails instead of being stored.

Scope: this change removes the post-terminal artifact (the model's property P', where the CANCELED status itself is
exempt). It does not make the cancel wait for its own CANCELED push: the push chain is asynchronous
(MainEventBusProcessor.java:475-505) and onCancelTask does not wait for it, so CANCELED may still be handed to the
push sender after the return (the test exempts CANCELED for this reason). Our model's second fix, part (b) (the cancel
waits for CANCELED on its tap and for the push chain), is not in this PR.

Tests (on main bc7f9d7, branch commit 600e6200, which adds the test): CancelLateArtifactPushTest (@RepeatedTest(5), 3 runs):
15 of 15 trials fail on main, 0 of 15 with the change. The server-common suite with the change: 677 tests, 1 failure,
DefaultRequestHandlerBuilderAuthorizationTest.emptyTaskIdWithoutEffectiveCardIsInvalid, which fails on main too in
the same offline build (only server-common built; sibling modules from cached snapshot jars).
Model (K = 2): with this change no artifact is handed to the push sender after the acknowledgement (0 of 298,802
executions, CANCELED exempt). At the POST, the asynchronous chain can still deliver an artifact handed over before the
cancel after the acknowledgement (63,505 of 2,225,095); part (b) removes that too (0 of 716,174). The native test
covers the post-terminal artifact only (the artifact is emitted after the return).

Not in this PR (noted in the issue thread if useful): onCancelTask returns on the first event of any kind on its tap
(ResultAggregator.java:155-171), not on CANCELED as the comment at DefaultRequestHandler.java:785-787 says, and
it does not wait for the task's push chain, so CANCELED itself may be pushed after the return. An event processed
just before CANCELED can make it answer TaskNotCancelableError while the task then ends CANCELED
(CancelNotCancelableYetCanceledTest, a separate observation: 15 of 15 trials, with or without this change).

Found with. We are a research team at MPI-SWS building Daavar, a conformance checker for distributed protocol
implementations. The post-terminal artifact was found by a JMC model of the cancel path with an adversary client and
confirmed natively on the SDK. This PR was prepared with AI assistance and reviewed by us.

Reproduce with Daavar (8161b57)
git clone https://github.com/joulook/daavar && cd daavar && git checkout 8161b57
git submodule update --init traceforge
(cd traceforge && cargo build --release -p traceforge --bin conf-join)
cd benchmarks/security-pilot/p3/AT-10
(cd port-rust && cargo build --release)
B=port-rust/target/release/tf_p3_at10; J=../../../../traceforge/target/release/conf-join
$B count impl --model causal --assertions-as-err -- javafixa,mon,handoff,excan,k2
$B count impl --model causal --assertions-as-err -- javafixa,mon,excan,k2

Printed (fresh clone at 8161b57, 2026-12-05): with this change, at the hand-off, execs=298802 blocked=0,
assertions: 0 execution(s) had a failed assertion (no artifact handed over after the acknowledgement); at the POST,
execs=2161590 blocked=63505, assertions: 63505 execution(s) had a failed assertion (an artifact handed over before
the cancel is still POSTed after it: the window this PR leaves).

A security issue of the effect-after-revocation kind (an effect follows the acknowledged cancel) under our stated authority contract; no MUST of A2A v1.0.0 is broken.

TaskManager.saveTaskEvent appended an artifact to a task whatever its
state. An agent that was still running after its task had been canceled
could therefore add an artifact to the CANCELED task: the artifact was
stored on the task and handed to the push notification sender after
CancelTask had answered CANCELED.

A task in a final state is now treated as immutable for artifacts, as it
already is for status changes. The artifact update is refused with the
same A2AServerException and InternalError that validateStateTransition
uses, so the event bus processor distributes the error and pushes
nothing.

This changes behaviour: an artifact update for a completed, failed or
canceled task now fails instead of being stored. It does not make the
cancel wait for its own CANCELED push notification, which is still sent
asynchronously.

Fixes: a2aproject#1391

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

after CancelTask is acknowledged, an artifact is still persisted on the CANCELED task and handed to the push sender

1 participant