Skip to content

Make unknown-token balance reads fail scripted runs - #126

Merged
portdeveloper merged 1 commit into
portdeveloper:mainfrom
ShadowOfTime1:fix/unknown-token-balance-refusal
Oct 13, 2026
Merged

portdeveloper merged 1 commit into
portdeveloper:mainfrom
ShadowOfTime1:fix/unknown-token-balance-refusal

Conversation

@ShadowOfTime1

Copy link
Copy Markdown
Contributor

Closes #124

get_token_balance answered a token it couldn't resolve with the bare Unknown 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 as Refused: ... (cli.mjs), so the balance read now does the same in runAction. 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", "", 0 and false are refusals through both runAction and native dispatchToolCall, and each still carries "Use a token contract address" and the known-symbol list.
  • test/native-tools-cli-exit.test.mjs: a new unknown-token scenario in the shimmed model runs the real dist/cli.mjs. The model reads NOT_A_TOKEN, gets the refusal, then replies normally, and the process still exits 1 with the Refused: Unknown token "NOT_A_TOKEN" line in the transcript.
  • The Answer an unreadable token identifier instead of throwing on it #123 control "an unknown symbol keeps the existing missing-token message rather than becoming a refusal" and the empty-catalog test now expect the refusal, since this issue changes exactly that. Everything else in them stays: MON is still native, a padded address still resolves, and Answer an unreadable token identifier instead of throwing on it #123's unreadable-value handling is untouched. Parser and send path are unchanged.

Without the one-line change, the four affected tests fail.

Verification: npm run build and npm test. The changed tests all pass. Locally the MCP subprocess tests fail on my machine, the same 12 on clean main as on this branch, so they are environment-related and not touched here.

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

@portdeveloper portdeveloper left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks

@portdeveloper
portdeveloper merged commit 955e9b5 into portdeveloper:main Oct 13, 2026
3 checks passed
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.

Make unknown-token balance reads fail scripted runs

2 participants