Skip to content

Comments

Resolve UseExisting string instead of leaking it to output#155

Merged
jlowin merged 2 commits intomainfrom
fix/use-existing-string-leak
Feb 3, 2026
Merged

Resolve UseExisting string instead of leaking it to output#155
jlowin merged 2 commits intomainfrom
fix/use-existing-string-leak

Conversation

@jlowin
Copy link
Member

@jlowin jlowin commented Feb 2, 2026

When the LLM returns the literal text "UseExisting" to signal that previous output is still valid, _extract and _complete pass it through as template output. Users see "UseExisting" rendered in their documents instead of the actual previous content.

The fix detects the "UseExisting" response and substitutes the previous output. The resolved value (not the sentinel string) is what gets recorded in the manifest, so downstream caching works correctly. The extract prompt template also now only mentions UseExisting when previous output actually exists, avoiding confusing the LLM when there's nothing to reuse.

Fixes #152

Copy link

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

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: 3777599b32

ℹ️ 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 on lines 17 to 18
{% if previous_output %}
Provide the extracted information. If previous output is still valid, respond with UseExisting instead.

Choose a reason for hiding this comment

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

P2 Badge Preserve UseExisting guidance when previous output is empty

The new {% if previous_output %} condition is false when the prior extraction output is the empty string, so the prompt omits both the previous output section and the UseExisting instruction even though a previous result exists. In that scenario (empty-string output with unchanged content), the LLM is no longer prompted to return UseExisting, so caching/stability can regress compared to prior behavior. Consider testing explicitly for previous_output is not none instead of truthiness so empty but valid outputs still enable the reuse path.

Useful? React with 👍 / 👎.


provider = LLMProvider(model=FunctionModel(return_use_existing))

from colin.compiler.cache import _serialize_value

Choose a reason for hiding this comment

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

P1 Badge Move _serialize_value import to module level

The repo’s AGENTS.md (Colin Development Guidelines) mandates that all imports be at module scope; the local from colin.compiler.cache import _serialize_value inside the test violates this rule and is likely to fail the required lint step (uv run prek run --all-files). Please move it to the module-level imports.

Useful? React with 👍 / 👎.

@jlowin jlowin merged commit b196a9a into main Feb 3, 2026
1 of 4 checks passed
@jlowin jlowin deleted the fix/use-existing-string-leak branch February 3, 2026 00:50
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.

LLM returns "UseExisting" as string (not UseExisting object)

1 participant