Skip to content

fix(config): keep dollar signs in {file:} reference contents - #754

Merged
Aayam Bansal (aayambansal) merged 1 commit into
synthetic-sciences:mainfrom
breken-ai:fix/config-file-reference-dollar
Sep 27, 2026
Merged

Aayam Bansal (aayambansal) merged 1 commit into
synthetic-sciences:mainfrom
breken-ai:fix/config-file-reference-dollar

Conversation

@breken-ai

Copy link
Copy Markdown
Contributor

What does this PR do, and why?

What: A config value that uses {file:…} does not get the file's text as written. An agent prompt loaded from {file:prompt.md} that contains display math $$E = mc^2$$ reaches the model as $E = mc^2$.

Why: resolveReferences in backend/cli/src/config/config.ts splices the file in with resolved.replace(reference, contents.trim()). When the replacement argument is a string, $$, $&, $` and $' in it are expanded as patterns.

Small example: a file containing $$x$$ and $& comes back as $x$ and {file:prompt.md}.

Why the existing test missed it: "handles file inclusion substitution" includes test_theme, which has no $.

Fix: pass a function, () => contents.trim(), which inserts the text verbatim. The {env:…} substitution just above already uses a function replacement.

Linked issue

Fixes #753

How did you verify it?

New test in backend/cli/test/config/config.test.ts: "file inclusion keeps dollar signs in the included text". It writes a real openscience.json with agent.physicist.prompt: "{file:prompt.md}" and reads it back through Config.get().

  • main (c296631): fails with "Energy: $E = mc^2$ … Keep {file:prompt.md} and and as written."
  • this branch: passes
  • bun test --timeout 15000 ./test/config: 119 pass, 0 fail
  • bun run typecheck (tsgo): clean
  • prettier --check on the changed files: clean

Other affected paths: the same class exists in $ARGUMENTS substitution for slash commands (session/prompt.ts). I kept that as a separate change so each fix stays reviewable on its own.

Checklist

  • bun run check is green (format, typecheck, backend + frontend/ui + SDK tests). I ran format, typecheck and the config suite. I did not run the full ten-minute backend suite; this change touches only resolveReferences.
  • bun run --cwd frontend/workspace build succeeds if I touched frontend/workspace or frontend/ui (not touched)
  • ./tooling/repo/generate.ts was run and the tooling/sdk output committed if I changed backend/cli/src/server (not touched)
  • CHANGELOG.md has an Unreleased entry if the change is user-visible
  • The matching docs page under frontend/docs/src/content/openscience/ is updated if behavior changed (documented behavior now holds, so there is no docs change)
  • Screenshots or a short video are attached for UI changes (no UI change)
  • No version bumps (package.json versions and tags are written by the release workflow)
  • install and frontend/landing/public/install are still byte-identical if I touched either (not touched)

AI disclosure: an AI agent (breken-ai) found this bug, wrote the fix and test, and ran the checks above.

The file text was spliced in with a string replacement, so replacement
patterns in the file were expanded: $$ became $, and $&, $` and $' pasted
parts of the config value. Use a function replacement.
@vercel

vercel Bot commented Sep 26, 2026

Copy link
Copy Markdown

breken (@breken-ai) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openscience Ready Ready Preview Sep 27, 2026 6:29am UTC

Request Review

@aayambansal
Aayam Bansal (aayambansal) merged commit ba152a6 into synthetic-sciences:main Sep 27, 2026
9 of 10 checks passed

This branch was successfully deployed

1 active deployment
Preview — 54b7e28b Deployed Sep 27, 2026 by vercel[bot]
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.

A {file:} config reference drops or rewrites dollar signs in the included text

2 participants