NetLogo / NetLogo/Netlogo-LLM-Extension
bug: async replies that complete after clear-all repopulate history and usage
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1
- Forks
- 0
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 4
Description
Problem
clearAll() in LLMExtension.scala clears messageHistory, agentUsage, runUsage and agentProfile under their locks, but nothing invalidates calls that are still in flight. Start llm:chat-async on the observer, call clear-all, then let the reply arrive: its completion callback runs recordUsage and commitExchange, so the previous run's tokens and exchange land in the freshly reset state. The separate history and usage locks also mean a reset can split those two updates.
Found by a Codex review on 2026-09-08. Predates today's changes for history (since #44); token usage (#78) extends the same gap.
Fix
Capture a run generation number when a request is launched; advance it in clearAll(); have recordUsage and commitExchange drop the update when the generation no longer matches. One counter under one lock keeps history and usage consistent.
Test
Start a __TEST_DELAY: async call, clear-all, resolve it with runresult, then assert llm:history is [] and llm:get llm:usage-total "calls" is 0.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in LLMExtension.scala, tracing llm:chat-async completion handling through recordUsage and commitExchange, then inspect clearAll() and its locks. Reproduce the __TEST_DELAY: scenario by running clear-all before resolving with runresult; done means llm:history remains [] and llm:get llm:usage-total "calls" remains 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100