Repository navigation
Make unknown-token balance reads fail scripted runs - #126
Merged
portdeveloper merged 1 commit intoOct 13, 2026
Merged
portdeveloper merged 1 commit into
portdeveloper merged 1 commit into
Conversation
get_token_balance answered a token it could not resolve with the bare "Unknown token ..." text, so isRefusal() was false and a scripted run finished with exit 0 after a balance read that never happened. The send path already prefixes the same explanation with "Refused:". The balance read now does too, keeping the known-symbol and contract-address hint. Tests cover "NOT_A_TOKEN", "", 0 and false through runAction and native dispatch, and a real dist/cli.mjs run with a shimmed model that reads an unknown token and then replies normally still exits 1. The portdeveloper#123 control for the unknown symbol and the empty-catalog message now expect the refusal; MON, known-token, contract-address and portdeveloper#123's unreadable-value handling are unchanged. Closes portdeveloper#124
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #124
get_token_balanceanswered a token it couldn't resolve with the bareUnknown token ...text.isRefusal()was false for it, so a scripted run finished with exit 0 after a balance read that never happened. The send path already wraps the same explanation asRefused: ...(cli.mjs), so the balance read now does the same inrunAction. The known-symbol and contract-address guidance is unchanged, and so is the empty-catalog wording, just prefixed.Tests:
test/tools.test.mjs:"NOT_A_TOKEN","",0andfalseare refusals through bothrunActionand nativedispatchToolCall, and each still carries "Use a token contract address" and the known-symbol list.test/native-tools-cli-exit.test.mjs: a newunknown-tokenscenario in the shimmed model runs the realdist/cli.mjs. The model readsNOT_A_TOKEN, gets the refusal, then replies normally, and the process still exits 1 with theRefused: Unknown token "NOT_A_TOKEN"line in the transcript.Without the one-line change, the four affected tests fail.
Verification:
npm run buildandnpm test. The changed tests all pass. Locally the MCP subprocess tests fail on my machine, the same 12 on cleanmainas on this branch, so they are environment-related and not touched here.