Skip to content

[feat][backend]: prompt upgrade for mcp&dlp&security_level#456

Merged
lizwang11 merged 65 commits into
mainfrom
feat/prompt_sync_2
Mar 25, 2026
Merged

[feat][backend]: prompt upgrade for mcp&dlp&security_level#456
lizwang11 merged 65 commits into
mainfrom
feat/prompt_sync_2

Conversation

@lizwang11
Copy link
Copy Markdown
Collaborator

@lizwang11 lizwang11 commented Mar 12, 2026

features:

  • support thinking config, mcp config, response api and custom tools
  • support security level for prompt
  • openapi upgrade

看一下feat/prompt\_sync\_1222这个分支和main的diff,帮我补齐所有差异的ut,并确保完整的ut测试通过,其中需要mock的统一使用mockgen来生成,你可参考其他test文件

写完之后,你可以使用go test ./... -v | grep FAIL 来测试
@/Users/bytedance/GolandProjects/coze-loop/backend/modules/prompt/domain/service/tool\_results\_collector\_test.go 需要使用mock ,使用mockgen 在@/Users/bytedance/GolandProjects/coze-loop/backend/modules/prompt/domain/service/mocks 中生成mock方法并使用,你可以参考 tool\_config\_test
参考下面的ut报告帮我补充一下对应的ut

❌ Patch coverage is `76.68919%` with `69 lines` in your changes missing coverage. Please review.

[Files with missing lines](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)Patch %Lines

[backend/modules/prompt/application/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9vcGVuYXBpLmdv)

15.78%

[29 Missing and 3 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)

[...nd/modules/prompt/application/convertor/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3Ivb3BlbmFwaS5nbw==)

77.77%

[10 Missing and 10 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)

[backend/modules/prompt/domain/service/execute.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Fexecute.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS9leGVjdXRlLmdv)

89.61%

[4 Missing and 4 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)

[...kend/modules/prompt/domain/entity/prompt\_detail.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fentity%2Fprompt_detail.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vZW50aXR5L3Byb21wdF9kZXRhaWwuZ28=)

83.33%

[3 Missing and 2 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)

[...end/modules/prompt/application/convertor/prompt.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fprompt.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3IvcHJvbXB0Lmdv)

84.61%

[2 Missing and 2 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)

❌ Your patch check has failed because the patch coverage (76.68%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the [target](https://docs.codecov.com/docs/commit-status#target) coverage.

[![Impacted file tree graph](https://camo.githubusercontent.com/f72f15574daff346298f0d18a8e0eb0647a91ef2042b383e5da8f19e06d8ed10/68747470733a2f2f6170702e636f6465636f762e696f2f67682f636f7a652d6465762f636f7a652d6c6f6f702f70756c6c2f3335352f6772617068732f747265652e7376673f77696474683d363530266865696768743d313530267372633d707226746f6b656e3d52505751574b544f56382675746d5f6d656469756d3d726566657272616c2675746d5f736f757263653d6769746875622675746d5f636f6e74656e743d636f6d6d656e742675746d5f63616d706169676e3d70722b636f6d6d656e74732675746d5f7465726d3d636f7a652d646576)](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm\_medium=referral&utm\_source=github&utm\_content=comment&utm\_campaign=pr+comments&utm\_term=coze-dev)

```javascript

@@           Coverage Diff            @@
##             main     #355    +/-   ##
========================================
  Coverage   69.76%   69.77%
========================================
  Files         616      618     +2
  Lines       58291    58501   +210
========================================
+ Hits        40666    40818   +152
- Misses      14637    14680    +43
- Partials     2988     3003    +15

```

[Flag](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)Coverage Δ

[unittests](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)

`69.77% <76.68%> (+<0.01%)`

⬆️

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#carryforward-flags-in-the-pull-request-comment) to find out more.

[Files with missing lines](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)Coverage Δ

[backend/modules/prompt/domain/service/service.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Fservice.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS9zZXJ2aWNlLmdv)

`100.00% <100.00%> (ø)`

[...ckend/modules/prompt/domain/service/tool\_config.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Ftool_config.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS90b29sX2NvbmZpZy5nbw==)

`100.00% <100.00%> (ø)`

[...es/prompt/domain/service/tool\_results\_collector.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Ftool_results_collector.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS90b29sX3Jlc3VsdHNfY29sbGVjdG9yLmdv)

`100.00% <100.00%> (ø)`

[...end/modules/prompt/application/convertor/prompt.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fprompt.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3IvcHJvbXB0Lmdv)

`83.46% <84.61%> (+0.01%)`

⬆️

[...kend/modules/prompt/domain/entity/prompt\_detail.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fentity%2Fprompt_detail.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vZW50aXR5L3Byb21wdF9kZXRhaWwuZ28=)

`85.31% <83.33%> (-0.94%)`

⬇️

[backend/modules/prompt/domain/service/execute.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Fexecute.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS9leGVjdXRlLmdv)

`77.21% <89.61%> (+0.50%)`

⬆️

[...nd/modules/prompt/application/convertor/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3Ivb3BlbmFwaS5nbw==)

`89.24% <77.77%> (-3.24%)`

⬇️

[backend/modules/prompt/application/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9vcGVuYXBpLmdv)

`85.92% <15.78%> (-5.39%)`

⬇️
lizwang11 and others added 8 commits February 6, 2026 15:51
* feat:prompt_release

* feat:prompt_release

* feat:prompt_release

* feat:prompt_release

* Feat/dlp sync (#419)

* feat: support dlp and security level for prompt

* feat: add prompt commit and draft dao hook

* feat: change permission check for ListParentPrompt

* fix: user draft save encrypt message

---------

Co-authored-by: wangluming.wlm <wangluming.wlm@bytedance.com>
@lizwang11 lizwang11 changed the title [feat][backend]: prompt upgrade for dlp [feat][backend]: prompt upgrade for mcp&dlp&security_level Mar 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 94.20152% with 61 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/modules/prompt/application/openapi.go 84.89% 25 Missing and 12 partials ⚠️
...end/modules/prompt/application/convertor/prompt.go 91.66% 5 Missing and 5 partials ⚠️
...pi/handler/coze/loop/apis/prompt_manage_service.go 0.00% 2 Missing ⚠️
...nd/modules/prompt/application/convertor/openapi.go 99.15% 1 Missing and 1 partial ⚠️
backend/modules/prompt/domain/service/execute.go 98.16% 1 Missing and 1 partial ⚠️
...es/prompt/domain/service/tool_results_collector.go 90.90% 1 Missing and 1 partial ⚠️
backend/modules/prompt/infra/repo/manage.go 90.90% 1 Missing and 1 partial ⚠️
backend/modules/prompt/infra/rpc/user.go 0.00% 2 Missing ⚠️
backend/modules/data/application/item_app.go 0.00% 1 Missing ⚠️
...modules/data/domain/dataset/service/import_file.go 0.00% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
+ Coverage   74.52%   75.08%   +0.55%     
==========================================
  Files         629      632       +3     
  Lines       66438    67215     +777     
==========================================
+ Hits        49511    50466     +955     
+ Misses      13646    13520     -126     
+ Partials     3281     3229      -52     
Flag Coverage Δ
unittests 75.08% <94.20%> (+0.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/infra/platestwrite/latest_write_tracker.go 22.72% <ø> (ø)
backend/modules/data/domain/dataset/entity/job.go 100.00% <100.00%> (ø)
...ackend/modules/llm/domain/entity/eino_convertor.go 86.95% <100.00%> (+1.08%) ⬆️
backend/modules/llm/domain/entity/runtime.go 100.00% <100.00%> (+3.63%) ⬆️
...y/domain/task/service/taskexe/tracehub/backfill.go 71.47% <100.00%> (+4.02%) ⬆️
...ules/prompt/application/convertor/debug_context.go 83.13% <100.00%> (+0.20%) ⬆️
backend/modules/prompt/application/debug.go 65.66% <100.00%> (+0.47%) ⬆️
backend/modules/prompt/application/manage.go 91.63% <100.00%> (+8.94%) ⬆️
...kend/modules/prompt/domain/entity/prompt_detail.go 98.87% <100.00%> (+12.62%) ⬆️
backend/modules/prompt/domain/repo/manage.go 100.00% <ø> (ø)
... and 14 more

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb284ff...51fd8c6. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- application/manage_test.go: add tests for UpdatePrompt, CommitDraft, GetPrompt, ListCommit error branches, CreatePrompt/ClonePrompt SecurityLevel defaults
- application/openapi_test.go: add tests for promptTypeToMetricValue, getRequest* helpers, normalizeExecuteRequest branches
- application/convertor/prompt_coverage_test.go: add tests for TokenUsageDO2DTO, BatchDebugToolCallDO2DTO, VariableVal, PromptCommit, McpConfig, ToolChoiceType, Scenario, nil element filtering
- application/convertor/openapi_coverage_test.go: add tests for ThinkingConfig, ThinkingOption, ReasoningEffort, ParamConfigValue, ToolChoiceSpecification, ContentPartDTO2DO branches
- domain/entity/prompt_detail_test.go: add tests for formatMultiPart, formatMessages, convertVariablesToMap, DeepEqual
- domain/service/execute_test.go: add tests for Signature field, DisableTracing, CollectToolResults error, streaming errors
- infra/metrics/paas_coverage_test.go: add tests for EmitPaasMetric nil guards, WithPaasStatus regular error, all With* functions no-context safety
- infra/repo/manage_test.go: add test for BatchGetPromptBasic partial result
# Conflicts:
#	backend/api/router/coze/loop/apis/middleware.go
#	backend/kitex_gen/coze/loop/prompt/openapi/coze.loop.prompt.openapi.go
#	backend/kitex_gen/coze/loop/prompt/openapi/coze.loop.prompt.openapi_validator.go
#	backend/kitex_gen/coze/loop/prompt/openapi/k-coze.loop.prompt.openapi.go
#	idl/thrift/coze/loop/prompt/coze.loop.prompt.openapi.thrift
- Keep domain_openapi/prompt.thrift include, add extra.thrift include from main
- Add extra.Extra field to BatchGetPromptByPromptKeyRequest and ExecuteRequest
- Keep ListPromptBasicRequest field 6 map<string,string> extra without extra.Extra to avoid name conflict
- Regenerate kitex_gen code
@lizwang11 lizwang11 requested a review from caijialin0626 March 25, 2026 02:56
@lizwang11 lizwang11 merged commit ee7c5d5 into main Mar 25, 2026
19 checks passed
@lizwang11 lizwang11 deleted the feat/prompt_sync_2 branch March 25, 2026 02:57
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.

3 participants