Files
dify/api/core/app
Yansong Zhang 87a57d8625 feat(api): prompt mention contract + runtime expansion — ENG-616
Slash-menu references are stored inline in the plain-string prompt as
{{#<kind>:<id>[|<label>]#}} tokens (kind: skill/file/tool/cli_tool/knowledge/
human/node_output/output). Mentions are pointers into the Agent config lists;
label is a plain-text fallback only — the backend re-resolves by id. The colon
form is invisible to the legacy template parsers, so no syntax collision.

- services/agent/prompt_mentions.py: parse/expand/scrub + per-surface allowlists
  + soul/node-job resolvers (tool ids accept provider|provider_id|plugin_id
  qualified aliases).
- composer_validator: enforce §2.4 allowlists at save/validate
  (mention_kind_not_allowed, mention_limit_exceeded as stable message codes).
- runtime: both run-request builders expand mentions to canonical names before
  sending to the agent backend; node_output expands to its reference name only
  (the value stays in the Workflow context block, per design §4.2); a final
  scrub pass guarantees no {{#…#}} marker ever reaches the model, while legacy
  {{#context#}} / {{#a.b#}} forms pass through untouched.

Design: Confluence 490012681 §2/§4. No DB changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:57:40 +08:00
..
2026-04-16 08:50:02 +00:00
2024-04-08 18:51:46 +08:00