Commit Graph

6516 Commits

Author SHA1 Message Date
2415ea0440 [autofix.ci] apply automated fixes 2026-06-10 10:18:15 +00:00
04f4ae2c4b Merge branch 'feat/agent-slash-menu-backend' of github.com:langgenius/dify into feat/agent-slash-menu-backend 2026-06-10 18:13:13 +08:00
6acab34149 fix 2026-06-10 18:12:43 +08:00
e6ad494e8f [autofix.ci] apply automated fixes 2026-06-10 09:01:17 +00:00
2be3ea43b7 mr 2026-06-10 16:56:31 +08:00
a03c7dd459 refactor(api): mention token uses [§kind🆔label§] with a single separator — ENG-616
Frontend review (Confluence 491028481) asked to drop the {{#…#}} wrapper (looks
like a Dify template variable) and unify the two separators into one. New token:

    [§<kind>:<id>[:<label>]§]

- [§…§] wrapper uses the section sign § (U+00A7) — never appears in Dify template
  syntax ({{var}} / {{#a.b#}}) nor in normal prompt text, so zero collision (a
  cleaner argument than the old colon-form-invisibility one).
- single ':' separates all three fields; label is the trailing remainder and may
  itself contain ':'.
- MENTION_PATTERN / residual-marker regex / scrub all updated; legacy {{#context#}}
  and {{var}} forms still pass through untouched.

Pure delimiter swap — parse/expand/scrub/validation semantics unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:47:20 +08:00
e8181c17e5 [autofix.ci] apply automated fixes 2026-06-10 07:48:54 +00:00
030bce4723 fix(api): dataset lookup tolerates malformed mention ids — ENG-617
A {{#knowledge:<id>#}} mention id is user-editable prompt text; a non-UUID id
hit the UUID-typed datasets query and 500'd validate/save (found live in E2E).
_dataset_rows now filters non-UUID ids before querying — they can never match a
row, so they read as missing (placeholder semantics).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 14:58:29 +08:00
ba8ddff696 feat(api): composer slash validations — human must be referenced + knowledge placeholder — ENG-617
Hard rule (PRD: human involvement must be slash-referenced or save errors):
every configured human contact must appear as {{#human:<id>#}} in its surface's
prompt (matched via any identity alias: id/contact_id/human_id/email/name;
identity-less contacts are skipped). Error code human_involvement_not_referenced,
enforced on both the agent soul prompt and the workflow job prompt.

Soft findings (never block save), returned by validate and attached to save
responses as `validation`:
- knowledge_retrieval_placeholder: dangling {{#knowledge:<id>#}} mentions (not
  in config, or configured-but-deleted in DB) are kept with a placeholder name
  (mention label, fallback "Knowledge <id8>") per the 0522 consensus, instead of
  being dropped or rejected; knowledge not referenced is fine.
- mention_target_missing: skill/file/tool/cli_tool/human/node_output/output
  mentions whose id resolves to no configured item.
- mention_malformed: mention-shaped markers the strict grammar rejects
  (degraded to plain text at runtime by the scrub pass).

Response models gain warnings/knowledge_retrieval_placeholder (validate) and
validation (save); validate endpoints now resolve dataset existence via the
tenant-scoped dataset lookup.

Design: Confluence 490012681 §5. Depends on the ENG-616 mention contract.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 14:51:31 +08:00
3044c732af feat(api): real slash-menu candidates data sources — ENG-615
The agent-composer candidates endpoints returned hardcoded empty arrays; node_id
and tenant were ignored. Now:

- workflow variant: previous_node_outputs computed from the draft workflow graph
  (WorkflowGraphTopology extracted from agent_v2 validators into
  core/workflow/graph_topology.py + new upstream_node_ids BFS). Output
  enumeration matches the Node Output Inspector: start variables + recorded
  sys.* are static, Agent v2 upstream nodes use their binding's effective
  declared outputs, all other kinds infer from the latest draft-run variables
  (inferred: true). Entries are emitted in the stored
  WorkflowPreviousNodeOutputRef shape (selector/node_id/output/name + display
  extras) so a selected candidate writes back into the config verbatim.
  human_contacts = the binding's configured node_job items (0522: defined only).
- soul variant (both variants): skills_files / cli_tools(enabled) /
  knowledge_datasets (enriched via DatasetService, dangling marked missing for
  the placeholder UX) / human_contacts from the agent's current soul config;
  dify_tools from BuiltinToolManageService.list_builtin_tools (same source as
  the tool selector; daemon outage degrades to an empty list, never a 500).
- per-list cap 200 + response-level truncated flag; all queries tenant-scoped;
  empty config returns empty lists.
- controllers pass tenant_id/user_id/node_id (with_current_tenant_id +
  with_current_user_id).

Design: Confluence 490012681 §3.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 14:19:13 +08:00
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
d849d60822 refactor(api): migrate tenant/user via DI for several endpoints (#37240) 2026-06-10 04:11:53 +00:00
ba9975a083 feat(dify-agent): sync shell and back proxy updates (#37159)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-10 03:04:32 +00:00
629e046303 refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-10 03:02:24 +00:00
212b819f1c test: migrate credit pool service tests to Testcontainers (#37252) 2026-06-10 01:55:50 +00:00
3fb1d3055e fix: agent mode missing file cards for BINARY_LINK and FILE type tool outputs (#36746)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-10 01:41:37 +00:00
28cc3fc10d chore: [Refactor/Chore] if isinstance to match case #35902 (#37087)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 09:54:04 +00:00
c88a38b8b5 chore(api): Suppress unknown contract checks by default (#36969)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 08:32:34 +00:00
1502a57381 feat(api,cli): strict UUID validation for app-id and workspace-id (#37212)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 07:35:18 +00:00
686e643632 chore(deps): bump starlette from 1.0.0 to 1.0.1 in /api (#37076)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-09 14:44:41 +08:00
11db079428 chore(deps): bump the storage group across 1 directory with 5 updates (#37153)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-09 14:43:22 +08:00
eb3b12fa70 fix(dataset): include segment created_at in hit testing response (#37181)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 05:15:36 +00:00
5bec8eb33a chore: filter unavailable apps from the installed apps list API (#37206)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 05:12:29 +00:00
d11e4eeaf7 chore: DI current_user && use inspect (#37084)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 05:06:28 +00:00
yyh
bbdf3d7634 fix(agent-v2): complete console API contract schemas (#37210)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 04:40:32 +00:00
a80bba2c35 feat(agent): Agent Files / agent Cloud storage — api backend (ENG-589) (#37172)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 04:01:05 +00:00
a8977be999 chore(api): convert AppContext from ABC to Protocol (#37203) 2026-06-09 03:16:39 +00:00
22e67b4673 chore(api): convert PipelineTemplateRetrievalBase from ABC to Protocol (#37201) 2026-06-09 03:14:50 +00:00
f948e442e0 chore(api): convert BaseQueueDispatcher from ABC to Protocol (#37200) 2026-06-09 02:56:29 +00:00
8a1c0cf5ab chore(api): convert BaseTruncator from ABC to Protocol (#37199) 2026-06-09 02:55:36 +00:00
5d814ca8c1 chore(api): convert RecommendAppRetrievalBase and WorkflowPauseEntity from ABC to Protocol (#37182) 2026-06-08 14:17:07 +00:00
0239b81cca chore(api): convert MessagesCleanPolicy from ABC to Protocol (#37171)
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-08 09:55:52 +00:00
a15ecf6bec feat(cli): adopt generated oRPC contract for unary endpoints (#37090)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-08 08:09:44 +00:00
f15a8f02ef ci: add flag for linter (#37018)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-08 04:53:12 +00:00
37e1d452b8 feat(api): add MCP user-identity forwarding (#36839)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-08 04:32:11 +00:00
db1aa683bc feat(web): gate /create and /refine slash commands behind feature preview flag (#37094)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 02:32:52 +00:00
813bfea730 feat(api): support embedded Excel images in knowledge import (#37104) 2026-06-08 01:26:07 +00:00
1ae98b3ea4 fix: remove unnecessary # type: ignore comments (#24494) (#37139) 2026-06-07 12:35:37 +00:00
196c040c99 chore: add missing @override decorators to api/repositories (#37138) 2026-06-07 12:08:22 +00:00
fad5656b2e fix(api): normalize empty workflow tool file lists (#37125) 2026-06-07 02:52:53 +00:00
76fb1b6ea8 refactor(api): remove redundant typing.cast calls (#37124) 2026-06-06 02:39:07 +00:00
157ba6f5a0 chore(api): Fix several typing errors (#37119)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-06 01:44:32 +00:00
6b12152ce8 refactor(api): migrate tenant/user via DI for several endpoints (#37114)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-05 15:08:11 +00:00
00ac937934 feat: snippet (#37046)
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-05 09:38:42 +00:00
24876bb05d fix: avoid duplicating lines when merging text for summarization (#37093)
Co-authored-by: bymle <229636660+bymle@users.noreply.github.com>
2026-06-05 07:02:57 +00:00
a1ad4be61e fix(api): expose device-flow approve rate limit as env var (#37083) 2026-06-05 02:56:23 +00:00
0bfbd2061e feat: enhance go to anything (#32130)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-04 11:06:17 +00:00
c8abb11bf0 feat: support custom trace session id for Phoenix tracing (#37056)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-04 08:42:03 +00:00
yyh
f9320b2c91 fix(api): return agent timestamps as epoch seconds (#37057)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-04 08:27:37 +00:00
b67c3a5f76 refactor(api): migrate tenant/user via DI for several endpoints (#37026) 2026-06-04 05:52:59 +00:00