NetLogo / NetLogo/Netlogo-LLM-Extension
bug: a refusal reply with null content throws in the parser and loses its token usage
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1
- Forks
- 0
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 4
Description
Problem
OpenAICompatibleProvider.parseProviderResponse reads message("content").str unconditionally. OpenAI's structured-output refusals return content: null with a refusal string and a full usage block. The parser throws before parseUsage runs, so the extension reports a parse failure and records neither the call nor its tokens, even though the provider billed them. Same shape can appear on any OpenAI-compatible provider.
Found by a Codex review on 2026-09-08. The parser assumption predates today's changes; the accounting consequence is new with #78.
Fix
Treat missing or null content as an empty string, carry the refusal text on the response (or surface it as the content with a clear marker), parse usage regardless, and let the calling primitive decide what to do with a refusal after recordUsage.
Test
A canned refusal body in UsageParsingSpec asserting usage is parsed, plus a tests.txt case asserting the call is counted.
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 at OpenAICompatibleProvider.parseProviderResponse and inspect how it reads message content before calling parseUsage. Add the canned refusal body to UsageParsingSpec and the usage assertion described there, then update tests.txt with the call-counting case. Done means null content no longer causes a parse failure, usage is retained, and the refusal call is counted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100