Skip to content

Ignore fenced examples in GLM fallback - #45

Merged
senamakel merged 5 commits into
mainfrom
fix/glm-fenced-examples
Oct 3, 2026
Merged

senamakel merged 5 commits into
mainfrom
fix/glm-fenced-examples

Conversation

@senamakel

@senamakel senamakel commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Exclude protected fenced examples from the GLM fallback used by parse_text, so quoted GLM-style commands are not reported as tool-call markup. Add a regression test for a fenced shell/command>ls example.

Verification

  • cargo fmt --check
  • cargo test -p tinytools-agent parse::test::markup::prose_a_bare_json_answer_and_a_quoted_example_are_not_markup

Summary by CodeRabbit

  • Bug Fixes
    • Fenced examples are now preserved in the returned narrative during fallback parsing, rather than being treated as executable calls.
    • Real calls outside fenced examples continue to be recognized, while discarded text remains excluded. This helps keep example markup visible without affecting which calls are parsed.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (2)
README.md — configured
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 056f3a13-c1d4-4ae6-822c-81fba8100f8d
📥 Commits

Reviewing files that changed from the base of the PR and between 8f18f7f and c95677f.

📒 Files selected for processing (3)
  • crates/tinytools-agent/src/parse/mod.rs
  • crates/tinytools-agent/src/parse/test/glm.rs
  • crates/tinytools-agent/src/parse/test/markup.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

When the initial scan finds no calls, GLM fallback parsing now processes kept text ranges separately and skips protected code fences. If it finds GLM calls, it returns the cleaned narrative and calls; otherwise, it retains the original scan result. Tests cover fenced examples and real calls.

Changes

GLM Fallback Parsing

Layer / File(s) Summary
Fallback parsing and validation
crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs
The no-call fallback parses kept ranges while leaving protected fence contents in the narrative. It uses the cleaned narrative when GLM calls are found and retains the original scan result otherwise. Tests check that fenced examples remain text and real calls are parsed.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c9567

Fenced examples remain text while real GLM calls are extracted. No merge-blocking issue was established.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: excluding fenced examples from GLM fallback parsing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks each text-filled line,
And leaves the fenced examples fine.
A real shell call hops from view,
Its command stays with it, too.
The rest of the tale stays true.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 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 ✅ Completed 2026-10-03T16:53:53.236755Z c95677f New commits
ℹ️ 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.

@tinysweeper

tinysweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

This pull request prevents fenced code examples from being misclassified as tool-call markup during the GLM fallback path. It introduces a new helper function and adds a related test case.

State: Incomplete
Priority: none
Reviewed head: c95677f31a7c
Updated: 1791046489 (Unix time)

Review snapshot

Change surface Files Review signal Count
Production 1 Active findings 1
Tests 2 Noted findings 0
Documentation 0 Resolved findings 3
Configuration 0 Pending checks/questions 6

Completeness: Incomplete
Test assessment: Test coverage is assessed from changed tests and lane evidence; execution is not claimed without trusted check data.

What changed

In `crates/tinytools-agent/src/parse/mod.rs`, the fallback logic that joins narrative parts before GLM parsing is replaced with a call to the new `unprotected_narrative` function (which excludes fenced ranges). A new `unprotected_narrative` function iterates over the `kept` ranges and the protected fenced ranges, extracting only non-fenced text portions, and joins them with newlines. In `crates/tinytools-agent/src/parse/test/markup.rs`, a test line is added to verify that a plain-text fenced block (```text\nshell/command>ls\n```) is not detected as call markup.

Features

  • Modified — GLM fallback narrative assembly: The line `let joined = parts.join("\n")` is replaced by `let joined = unprotected_narrative(text, &scan.kept)`. This changes what string is passed to `grammar::glm::parse_and_strip`, ensuring fenced content is omitted, which reduces false positives in tool-call markup detection. (crates/tinytools-agent/src/parse/mod.rs#pub fn parse_text(text: &str, options: &ParseOptions<'_>) -> ParseOutcome {)

Tests

  • regression test addition — Verifies that a string containing a fenced code block with plain text content (```text\nshell/command>ls\n```) is not recognized as call markup.: The test looks sound and correctly follows the intent of the change, but the lane review notes that the new `unprotected_narrative` function has no dedicated behavioural test and relies solely on the integration path. The reviewer flagged that a test to exercise the new helper directly is needed before merging. (crates/tinytools-agent/src/parse/test/markup.rs#fn prose_a_bare_json_answer_and_a_quoted_example_are_not_markup() {)

Findings

Previously reported and still active

  • Cover the new `unprotected\_narrative` function with a behavioural test

Resolved this pass

  • Cover the new `unprotected_narrative` function with a behavioural test
  • Cover the new `unprotected_narrative` function with a behavioural test
  • Cover the new `unprotected_narrative` function with a behavioural test

Could not review: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs

Before merge

  • Address carried finding Cover the new `unprotected\_narrative` function with a behavioural test.
  • Complete the critique review for crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs.
  • Complete the security review for crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs.

How this fits together

flowchart LR
  n0["parse_text<br/>changed"]:::changed
  n1["parse_response"]:::impacted
  n2["parse_response"]:::impacted
  n3["parse_tool_calls"]:::impacted
  n4["resolve_names"]:::impacted
  n5["scan"]:::impacted
  n6["ParsedToolCall"]:::impacted
  n0 -->|calls| n5
  n1 -->|calls| n0
  n2 -->|calls| n0
  n3 -->|calls| n0
  n3 -->|uses| n6
  n4 -->|uses| n6
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading
Agent review details

critique

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs
  • Lane summary: Reviewed 0 files; 0 findings. 3 files could not be reviewed: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs.

security

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs
  • Lane summary: Reviewed 0 files; 0 findings. 3 files could not be reviewed: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs.

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The change extracts a new `parse_unprotected_glm` function, adds tests that cover the new code, and moves fenced-example preservation from the old inline loop into the new function. The tests assert that GLM calls outside fences are parsed while fenced content is kept in the returned narrative. The existing earlier findings about covering this function with behavioural tests are now resolved by the two new tests. Behaviour appears unchanged, and all paths are exercised. (1 earlier finding(s) still open) _Code retrieval was unavailable (model: ladder embeddings returned 402 Payment Required: {"error":"Insufficient USD or Diem balance to complete request. Visit https://venice\.ai/settings/api to add credits."}), so this review saw the diff alone._ _5 memory call(s) failed (model: cortex: v1/recall: timed out after 10s), so this review saw part of what the engine holds._

commits

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: Nothing sensitive found in what this pull request commits.

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The change excludes fenced code blocks from GLM fallback parsing, preserving them in the narrative, and adds regression tests. It appears safe to merge. (1 earlier finding(s) still open) _Code retrieval was unavailable (model: ladder embeddings returned 402 Payment Required: {"error":"Insufficient USD or Diem balance to complete request. Visit https://venice\.ai/settings/api to add credits."}), so this review saw the diff alone._ _5 memory call(s) failed (model: cortex: v1/recall: timed out after 10s), so this review saw part of what the engine holds._

e2e

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: No end-to-end harness in this repository: no e2e test files and no e2e workflow.
Evidence and run details
  • Models: deepseek/deepseek-v4-flash
  • Spend: $0.000848
  • Tokens: 21425 input · 18325 output · 9786 cached · 0 embedding
Head State Pass summary
8e5008c375f9 incomplete 1 active finding(s), 0 resolved finding(s) (at 1791014501)
c95677f31a7c incomplete 0 active finding(s), 3 resolved finding(s) (at 1791046489)

tinysweeper 0.1.0

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e5008c375

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/tinytools-agent/src/parse/mod.rs Outdated

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tinysweeper found nothing blocking, but could not review everything, so this is not an approval: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/markup.rs.

             $0.0004 · 10,326 in / 1,394 out · 0 cached (0%) · deepseek/deepseek-v4-flash
tests:       $0.0002 · 4,308 in  / 620 out   · 0 cached (0%) · deepseek/deepseek-v4-flash
description: $0.0001 · 3,789 in  / 74 out    · 0 cached (0%) · deepseek/deepseek-v4-flash

Comment thread crates/tinytools-agent/src/parse/mod.rs Outdated
@senamakel senamakel self-assigned this Oct 3, 2026
senamakel and others added 4 commits October 3, 2026 19:48
Adds a test covering a real glm call where a fenced code block contains a tool-call-like line that should not be parsed as a call. The test verifies that only the actual call outside the fence is extracted and that the fenced content remains intact in the text output.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The unprotected narrative function now parses GLM calls directly while preserving fenced examples, instead of returning raw text for a separate parsing pass. This consolidates the GLM fallback logic into a single function that returns both the cleaned narrative and any parsed tool calls, eliminating the need for a second parse step and reducing redundant processing.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds a test covering the case where a fenced text block falls entirely within a kept range during GLM fallback parsing, ensuring the fence content is preserved while the discarded prefix and the real command after the fence are handled correctly.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The test now passes the kept range as a slice reference rather than a direct range, matching the updated signature of `parse_unprotected_glm` which expects a slice of ranges. This ensures the test exercises the function with the correct argument type while preserving the original assertion of fenced text retention.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

tinysweeper found nothing blocking, but could not review everything, so this is not an approval: crates/tinytools-agent/src/parse/mod.rs, crates/tinytools-agent/src/parse/test/glm.rs, crates/tinytools-agent/src/parse/test/markup.rs.

             $0.0008 · 21,425 in / 18,325 out · 9,786 cached (46%) · deepseek/deepseek-v4-flash
tests:       $0.0002 · 5,419 in  / 155 out    · 0 cached (0%)      · deepseek/deepseek-v4-flash
description: $0.0001 · 9,897 in  / 16,071 out · 4,411 cached (45%) · deepseek/deepseek-v4-flash

@senamakel
senamakel merged commit 1c58197 into main Oct 3, 2026
16 checks passed
@senamakel
senamakel deleted the fix/glm-fenced-examples branch October 3, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant