Skip to content

fix(prompts): stop showing example ids the model cannot legitimately send - #5320

Open
yh928 wants to merge 2 commits into
tinyhumansai:mainfrom
yh928:fix/prompt-placeholders
Open

fix(prompts): stop showing example ids the model cannot legitimately send#5320
yh928 wants to merge 2 commits into
tinyhumansai:mainfrom
yh928:fix/prompt-placeholders

Conversation

@yh928

@yh928 yh928 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Six tool schemas showed an example value for an id-shaped argument. Each now names the call that issues the real id instead.
  • The extract_from_result handle loses its example entirely: no example of a runtime-minted handle can ever be valid.

Problem

A sample is the shape a model reproduces, so the model sends the sample.

extract_from_result documented result_id as res_1. Two live runs called it with the literal res_1 against a cache that had never issued a handle, and both got a cache-miss instead of the data they wanted.

The same shape appeared in memory_goals edit/delete ((e.g. 'g1') — ids are sequential, so a guess deletes a real goal), the memory query source / cover window / memory-tree retrieval schemas ((e.g. \slack:#eng`)— source ids onlytree.list_sources can produce), and the browser element selector (@ref (e.g. @e1)` — refs change every navigation).

Solution

Each description now names where the real id comes from. No prohibition rules and no parser tolerance were added — the fix is what the schema shows. A rule saying "do not guess" competes with an example that shows a guessable value, and the example wins; widening the parser or the cache to accept a fabricated id would turn a wasted turn into a wrong result.

The extract_from_result case carries a code comment recording the two live runs, so the example is not reintroduced as a readability improvement.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case)
  • Diff coverage ≥ 80% — prompt-text only; the changed lines are schema strings exercised by the existing tool-schema tests
  • N/A: behaviour-only change, no feature row added/removed/renamed — Coverage matrix updated
  • No new external network dependencies introduced
  • N/A: no release-cut surface touched — Manual smoke checklist updated
  • Linked issue closed via Closes #NNN in the ## Related section

Impact

  • No runtime behaviour changes; these are description strings the model reads.
  • Platform-neutral. No migration.

Related

Closes #5316

Summary by CodeRabbit

  • Documentation
    • Clarified that result handles, source IDs, goal IDs, and browser snapshot references must be copied from valid, previously returned results.
    • Removed fabricated identifier examples from tool and parameter descriptions.
    • Clarified that source IDs are provider-specific and guessed goal IDs may affect real goals.
    • Documented result-handle expiration and advised rerunning the original tool when a handle is unavailable.
    • Clarified that browser references must come from the latest page snapshot.
    • Retained support for CSS and text-based browser selectors.

@yh928
yh928 requested a review from a team August 2, 2026 12:39
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94e44f81-3c5f-4bdc-8fb5-5890f18217ef

📥 Commits

Reviewing files that changed from the base of the PR and between d75b0a4 and 2a4f0ae.

📒 Files selected for processing (7)
  • src/openhuman/agent/harness/subagent_runner/extract_tool.rs
  • src/openhuman/memory/goals/schemas.rs
  • src/openhuman/memory/goals/tools.rs
  • src/openhuman/memory/query/cover_window.rs
  • src/openhuman/memory/query/query_source.rs
  • src/openhuman/memory/tree/retrieval/schemas.rs
  • src/openhuman/tools/impl/browser/browser.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/openhuman/tools/impl/browser/browser.rs
  • src/openhuman/memory/goals/schemas.rs
  • src/openhuman/memory/query/query_source.rs
  • src/openhuman/agent/harness/subagent_runner/extract_tool.rs
  • src/openhuman/memory/tree/retrieval/schemas.rs
  • src/openhuman/memory/goals/tools.rs
  • src/openhuman/memory/query/cover_window.rs

📝 Walkthrough

Walkthrough

Tool schemas now require runtime-issued result handles, memory source IDs, goal IDs, and browser references instead of fabricated example values.

Changes

Runtime identifier documentation

Layer / File(s) Summary
Result handle documentation
src/openhuman/agent/harness/subagent_runner/extract_tool.rs
The extraction tool requires exact handles from oversized-result placeholders and documents cache-expiry recovery. Tests verify the model-facing text.
Memory identifier documentation
src/openhuman/memory/goals/*, src/openhuman/memory/query/*, src/openhuman/memory/tree/retrieval/schemas.rs
Goal IDs must come from read goal lists. Memory source IDs must come from tree.list_sources and match provider-specific values exactly.
Browser reference documentation
src/openhuman/tools/impl/browser/browser.rs
Browser @ref values must come from the latest page snapshot.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: rust-core, bug

Suggested reviewers: m3ga-mind

Poem

A rabbit checks each schema line,
Real handles now appear on time.
Goals come from lists already read,
Sources use the IDs they shed.
Snapshot references stay aligned.

🚥 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 summarizes the primary change: removing fabricated example IDs from model-facing tool schemas.
Linked Issues check ✅ Passed The changes replace fabricated IDs with references to the calls that provide valid IDs across all schemas listed in issue #5316.
Out of Scope Changes check ✅ Passed All documented changes update model-facing ID descriptions and remain within the scope of issue #5316.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@coderabbitai coderabbitai Bot added bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. labels Aug 2, 2026
@greptile-apps

greptile-apps Bot commented Aug 2, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a class of model hallucination bugs caused by example identifiers in tool schema descriptions. When a schema shows result_id="res_1" or id='g1', the model treats those literals as templates and reproduces them verbatim — causing cache misses on extract_from_result (documented by two live production runs), silent mutations of wrong goals on memory_goals edit/delete, and stale selector refs in browser interactions.

  • extract_from_result: removes the res_1 example entirely and adds a code comment recording the two live misuse runs; the description now instructs the model to copy the handle from an actual placeholder.
  • memory_goals edit/delete (both schemas.rs and tools.rs): replaces (e.g. 'g1') with "taken from a goals list you have read"; the tools.rs version also adds an explicit warning that sequential IDs mean a guessed value mutates a real goal.
  • memory/query and memory/tree/retrieval: replaces the slack:#eng / gmail:abc examples with "copied from tree.list_sources" across four description sites.
  • browser.rs: changes @ref (e.g. @e1) to "@ref copied from the latest page snapshot", reflecting that refs are navigation-scoped and cannot be guessed.

Confidence Score: 5/5

Safe to merge — all changes are description strings with no runtime logic modifications.

Every changed line is a description or comment string that the model reads but the runtime never parses. No control flow, data model, or API surface is touched. The fix is narrowly scoped and directly addresses two documented production failures.

Files Needing Attention: No files require special attention. The minor wording difference between schemas.rs (no sequential-ID risk note) and tools.rs (includes the warning) is an intentional style difference between the RPC controller schema and the agent tool schema surfaces.

Important Files Changed

Filename Overview
src/openhuman/agent/harness/subagent_runner/extract_tool.rs Removes the res_1 example from the result_id parameter description; adds a code comment recording two live production misuse runs to prevent the example from being re-introduced.
src/openhuman/memory/goals/schemas.rs Replaces "(e.g. 'g1')" with "taken from a goals list you have read" for edit and delete id fields; the sequential-ID risk warning present in tools.rs is not repeated here.
src/openhuman/memory/goals/tools.rs Replaces "(e.g. 'g1')" with instructional text plus an explicit "Ids are sequential, so a guessed one lands/deletes a real goal you never looked at" warning for both edit and delete.
src/openhuman/memory/query/cover_window.rs Replaces the slack:#eng / gmail:abc example with "copied from tree.list_sources" for the source_id field.
src/openhuman/memory/query/query_source.rs Same source_id description fix as cover_window.rs — example replaced with "copied from tree.list_sources".
src/openhuman/memory/tree/retrieval/schemas.rs Two source_id FieldSchema comment strings updated — both drop the slack:#eng / gmail:abc examples in favour of "copied from tree.list_sources".
src/openhuman/tools/impl/browser/browser.rs Changes @ref (e.g. @e1) to "@ref copied from the latest page snapshot" in the selector description, preventing the model from guessing stale element references across navigations.

Sequence Diagram

sequenceDiagram
    participant M as Model
    participant S as Schema description
    participant T as Tool runtime
    participant C as Cache / Store

    Note over M,C: Before this PR
    S-->>M: result_id handle example res_1
    M->>T: extract_from_result result_id res_1
    T->>C: lookup res_1
    C-->>T: cache-miss
    T-->>M: Error

    Note over M,C: After this PR
    S-->>M: Copy handle from earlier result
    M->>T: some_tool returns placeholder result_id res_abc42
    M->>T: extract_from_result result_id res_abc42
    T->>C: lookup res_abc42
    C-->>T: hit
    T-->>M: extracted answer
Loading

Reviews (2): Last reviewed commit: "fix(prompts): stop showing example ids t..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/agent/harness/subagent_runner/extract_tool.rs`:
- Line 192: Update the description of the oversized tool output placeholder
handle to state that emitted handles may expire after cache eviction; when a
handle is no longer valid, rerun the original tool to obtain a new result
instead of sending the expired handle.
- Around line 170-183: Add focused semantic regression tests for the
runtime-identifier model-facing descriptions: in
src/openhuman/agent/harness/subagent_runner/extract_tool.rs:170-183 verify exact
placeholder-handle copying and no fabricated handles, and at 192 verify no-stash
guidance; test source_id guidance in cover_window at
src/openhuman/memory/query/cover_window.rs:43 and query_source at
src/openhuman/memory/query/query_source.rs:31; test the query_source and
cover_window controller schemas in
src/openhuman/memory_tree/retrieval/schemas.rs:106 and 168; test edit and delete
goal-ID guidance in src/openhuman/memory_goals/schemas.rs:94 and 118; test
GoalsEditTool and GoalsDeleteTool in src/openhuman/memory_goals/tools.rs:133 and
185; and test snapshot references plus CSS/text selector support in
src/openhuman/tools/impl/browser/browser.rs:773.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f6e103a-c320-4966-9c52-24c5a1e06a35

📥 Commits

Reviewing files that changed from the base of the PR and between a52a599 and ef5be20.

📒 Files selected for processing (7)
  • src/openhuman/agent/harness/subagent_runner/extract_tool.rs
  • src/openhuman/memory/query/cover_window.rs
  • src/openhuman/memory/query/query_source.rs
  • src/openhuman/memory_goals/schemas.rs
  • src/openhuman/memory_goals/tools.rs
  • src/openhuman/memory_tree/retrieval/schemas.rs
  • src/openhuman/tools/impl/browser/browser.rs

Comment thread src/openhuman/agent/harness/subagent_runner/extract_tool.rs Outdated
Comment thread src/openhuman/agent/harness/subagent_runner/extract_tool.rs Outdated
…send

Six tool schemas illustrated an id-shaped argument with a sample value. A
sample is the shape a model reproduces, so it sent the sample.

`extract_from_result` showed `result_id="res_1"`. Two live runs called it with
`res_1` against a cache that had never issued a handle, and both got a
cache-miss instead of the data they wanted. A handle is minted at runtime and
only exists once a result was actually stashed, so no example of one can ever
be valid — the fix is to show none and say where the real one comes from.

The same shape appeared in five more places:

- `memory_goals` edit/delete — `(e.g. 'g1')`. Goal ids are sequential, so a
  guessed one lands on, or deletes, a real goal the model never looked at.
- `memory` query source + cover window, and the memory-tree retrieval schema —
  `(e.g. `slack:#eng`, `gmail:abc`)`. Source ids are provider-specific strings
  only `tree.list_sources` can tell you.
- the browser element selector — `@ref (e.g. @e1)`. Refs come from the latest
  page snapshot.

Each now names the call that issues the id instead of inventing one. No
prohibition rules and no parser tolerance were added: the fix is what the
schema shows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SRSNnqQsokuGmkbpLoLCGy
@yh928
yh928 force-pushed the fix/prompt-placeholders branch from ef5be20 to 352f770 Compare August 5, 2026 01:54
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

yh928 added a commit to yh928/openhuman that referenced this pull request Aug 5, 2026
…tract

Two halves of one rule. The text says a handle is only valid if it appeared in
an earlier result, but not that one can stop being valid — the cache holds a
bounded number of recent entries, and `execute` already answers an evicted
handle with "re-run the original tool". Unsaid, an eviction reads to the model
as "wrong handle", which invites exactly the guess this PR removed the sample
handle to stop. Now stated where the model reads it.

Adds the regression the descriptions had none of: no model-facing text may
contain a handle-shaped literal (`res_1` and friends), and `result_id` must
still say where a real handle comes from and that it expires. A description is a
prompt, and an example in it is an instruction — the removal has to be pinned or
the next edit helpfully adds the example back. Two live runs called this tool
with `res_1` against a cache that had never issued one.

`description` and `parameters_schema` are lifted to free functions so the test
can read them without a live cache and model source; the trait methods delegate.

extract_tool 5 pass.

Reported by CodeRabbit on tinyhumansai#5320.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SRSNnqQsokuGmkbpLoLCGy

@greptile-apps greptile-apps 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.

yh928 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@yh928

yh928 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Markdown Link Check is red on this head, and it is not this branch: the run reports 0 errors and 10 timeouts against external hosts, and the branch touches no markdown at all (seven .rs files). It needs a re-run rather than a change here — I don't have permission to trigger one.

Everything else on this head is green, and both review threads are addressed in e4df37cbe.

…tract

Two halves of one rule. The text says a handle is only valid if it appeared in
an earlier result, but not that one can stop being valid — the cache holds a
bounded number of recent entries, and `execute` already answers an evicted
handle with "re-run the original tool". Unsaid, an eviction reads to the model
as "wrong handle", which invites exactly the guess this PR removed the sample
handle to stop. Now stated where the model reads it.

Adds the regression the descriptions had none of: no model-facing text may
contain a handle-shaped literal (`res_1` and friends), and `result_id` must
still say where a real handle comes from and that it expires. A description is a
prompt, and an example in it is an instruction — the removal has to be pinned or
the next edit helpfully adds the example back. Two live runs called this tool
with `res_1` against a cache that had never issued one.

`description` and `parameters_schema` are lifted to free functions so the test
can read them without a live cache and model source; the trait methods delegate.

extract_tool 5 pass.

Reported by CodeRabbit on tinyhumansai#5320.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SRSNnqQsokuGmkbpLoLCGy
@yh928
yh928 force-pushed the fix/prompt-placeholders branch from e4df37c to 2a4f0ae Compare August 5, 2026 08:19

@greptile-apps greptile-apps 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.

yh928 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@yh928

yh928 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my earlier comment: the link check has since passed on this head, so no re-run is needed. It was a transient timeout against external hosts (the failing run reported 0 errors and 10 timeouts), and the branch touches no markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Tool schemas illustrate ids with sample values the model then sends

1 participant