LAB / 024

Java LLM practice (9): why can a cancelled answer overwrite a new conversation?

18 controlled thread schedules test request ownership for streaming previews, completion and errors, with cancellation and bounded deduplication.

Completed ·

EXPERIMENT RESULT

GitHub ↗

01 / QUESTION

18 controlled thread schedules test request ownership for streaming previews, completion and errors, with cancellation and bounded deduplication.

METHOD

A real worker and main thread run nine fixed schedules under two policies; synthetic in-memory SSE reuses the A6 parser.

RESULT

18 executions: seven naive schedules violate the contract; all nine ownership-guarded schedules pass, with seven additional contract groups.

OBSERVATIONS

Late previews and errors can corrupt intermediate state even without a final overwrite; completeness does not imply current ownership.

CONCLUSION

Preview, completion and failure must validate ownership and mutate state in the same critical section.

LIMITATIONS

Local deterministic schedules, not an online failure rate. Cancellation does not stop billing; IDs have a finite in-process retention window.

REPRODUCE

Pinned code and raw records are in the repository; the article provides run, audit and replay commands.

KEEP EXPLORING

Related content

  1. Engineering cases

    Java LLM practice (9): why can a cancelled answer overwrite a new conversation?

    18 controlled thread schedules test request ownership for streaming previews, completion and errors, with cancellation and bounded deduplication.

    10 MINPublished
  2. PROJECT / 002

    Java LLM Practice

    Reproducible Java conversation, retry and persistence boundaries, alongside attention, cache-cost and quantization-error experiments.

    Building
  3. Engineering cases

    Java LLM practice (8): should an interrupted stream enter conversation history?

    22 loopback HTTP cases separate incremental preview from committing history, testing UTF-8, SSE framing, cancellation and abnormal endings.

    11 MINPublished
  4. Tutorials

    Calling an LLM with Java 8 — from one request to a conversation

    Three runnable Java demos explain HTTP requests, JSON parsing, timeouts and conversation history.

    15 MINPublished

← Back to index