Skip to content

fix(examples): ask LlmErc20 for single-brace JSON - #1798

Merged
danieljrc888 merged 1 commit into
v0.123-devfrom
fix/llm-erc20-prompt-braces
Oct 23, 2026
Merged

danieljrc888 merged 1 commit into
v0.123-devfrom
fix/llm-erc20-prompt-braces

Conversation

@danieljrc888

Copy link
Copy Markdown
Contributor

Delivery context

What

  • examples/contracts/llm_erc20.py: the response-format block in task used {{ ... }}. task is a plain string (not an f-string), so the doubled braces reached the LLM literally. Now uses single braces, matching what prompt_input (an f-string) already renders.

Why

  • A real model follows the prompt template and answers {{"transaction_success": true, ...}}, which json.loads in the contract rejects (Expecting property name enclosed in double quotes: line 1 column 2).
  • tests/integration/icontracts/tests/test_llm_erc20.py failed this way on the fix(fees): reserve parent appeal capacity in Studio message allocations #1784 review CI runs (run 39813769034, twice) and on 2026-09-10 (run 34472139849): the mock did not apply, all validators fell through to the real provider, computed the right balances (900/100) and returned them wrapped in double braces.
  • The example is also offered in the Studio UI, so users running it against a real LLM hit the same parse error.

Testing done

  • AST check over examples/contracts/*.py and tests/integration/icontracts/contracts/*.py: no other plain (non f-) string contains {{; the original llm_erc20.py is flagged, the fixed one is not.
  • The integration test's mock key (transactions between users) is in prompt_input, unchanged.
  • Integration CI runs on approval.

Decisions made

  • Why the mock sometimes does not apply is a separate investigation (validators are replaced via sim_replaceValidators inside the serialized mock_validators xdist group; suspect timing between that call and the consensus worker's validator snapshot). This PR only removes the double-brace failure mode.

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR
  • I have set a descriptive PR title compliant with conventional commits

User facing release notes

The LLM ERC20 example contract now asks the model for valid JSON, so transfers no longer fail to parse when run against a real LLM.

The response-format block lives in a plain (non f-) string, so the
doubled braces reached the LLM literally. A real model follows the
template and answers `{{...}}`, which json.loads rejects. This made
test_llm_erc20 fail whenever the mock did not apply and the call fell
through to the real provider (CI runs on #1784, 2026-09-10).

Co-Authored-By: Claude <noreply@anthropic.com>
@danieljrc888 danieljrc888 self-assigned this Oct 22, 2026
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 366a0c29-2d39-4622-9e18-26ab1ec97f65

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-22T23:15:18.003938Z 3c88786 PR opened
🔒 Security Review ✅ Completed 2026-10-22T23:17:44.217858Z 3c88786 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danieljrc888
danieljrc888 merged commit 9c5b786 into v0.123-dev Oct 23, 2026
20 of 21 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.

1 participant