Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Nov 17, 2025

  • Use @link format instead of / for cell link serialization to LLM tools
  • Add @arrayEntry decorator for array elements that reference cells
  • Handle any schema types by converting to cell links when appropriate
  • Add base64 validation to prevent false positive link detection
  • Add timeout handling for tool calls (30s timeout)
  • Refactor chatbot.tsx to use patternTool helper for listMentionable
  • Fix schema.ts to properly copy values before annotation to avoid mutations

Summary by cubic

Switches LLM tool serialization to the new "@link" format with smarter handling for any-schema and array entries to make responses clearer and safer. Adds tool call timeouts and includes schema in read responses.

  • New Features

    • Serialize cell refs as {"@link": ...}; decorate array items with "@arrayEntry".
    • Convert values with any schema into links when they point to cells.
    • Output schema alongside read JSON.
    • Add 30s timeout for tool calls to avoid hanging executions.
    • Refactor chatbot listMentionable to use patternTool for simpler wiring.
  • Bug Fixes

    • Copy objects/arrays before schema annotation to avoid mutations and fix seen cache tracking.
    • Return null for undefined read values and always clean up timers/sinks on tool execution.

Written for commit fb06802. Summary will update automatically on new commits.

…and any-schema handling

- Use `@link` format instead of `/` for cell link serialization to LLM tools
- Add `@arrayEntry` decorator for array elements that reference cells
- Handle `any` schema types by converting to cell links when appropriate
- Add base64 validation to prevent false positive link detection
- Add timeout handling for tool calls (30s timeout)
- Refactor chatbot.tsx to use patternTool helper for listMentionable
- Fix schema.ts to properly copy values before annotation to avoid mutations
@seefeldb seefeldb requested a review from bfollington November 17, 2025 23:09
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 5 files

Prompt for AI agents (all 3 issues)

Understand the root cause of the following 3 issues and fix them.


<file name="packages/runner/src/schema.ts">

<violation number="1" location="packages/runner/src/schema.ts:840">
When cloning the record before annotation, you also need to update the freshly pushed `seen` entry to point at the cloned value; otherwise future reads will return the outdated original object and lose the back-to-cell annotations.</violation>
</file>

<file name="packages/runner/src/builtins/llm-dialog.ts">

<violation number="1" location="packages/runner/src/builtins/llm-dialog.ts:1427">
handleRead now returns `{ type: &quot;json&quot;, value: serialized }` even when the cell value is `undefined`, so the tool response sends `{ value: undefined }`, which is not valid JSON and violates Anthropic&#39;s tool_result contract.</violation>

<violation number="2" location="packages/runner/src/builtins/llm-dialog.ts:1541">
`clearTimeout(timeout)` and `cancel()` aren’t wrapped in a `finally`, so any rejected tool call (including timeouts) leaves the timeout and result sink running, leaking resources and risking multiple resolves.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

This reverts the base64 validation and stricter link detection changes
in link-utils.ts and link-utils.test.ts to align with the main branch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
1. Fix seen cache tracking for cloned objects in validateAndTransform
   - Push cloned value to seen cache instead of original value
   - Ensures future circular reference checks return properly annotated objects

2. Handle undefined cell values in handleRead tool
   - Convert undefined to null (valid JSON) to comply with Anthropic's tool_result contract
   - Prevents invalid JSON responses when cell values are undefined

3. Prevent resource leaks in tool call execution
   - Wrap cleanup code (clearTimeout/cancel) in finally block
   - Ensures resources are freed even when tool calls timeout or reject

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@seefeldb seefeldb merged commit a5af518 into main Nov 17, 2025
2 checks passed
@seefeldb seefeldb deleted the feat/llm-friendly-link-for-any-on-deserialization branch November 17, 2025 23:55
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.

2 participants