fix(expense): reject unknown employees in quota query instead of returning a default quota - #258
Open
BlueX888 wants to merge 1 commit into
Open
Conversation
…rning a default quota expense.quota_query previously hit an external demo server that returned a 20,000 CNY quota for any employee_id, so an unknown employee (e.g. 张三 / 工号 666) was reported back as a real, funded employee. - Point the tool at the in-repo mock (/api/mock/expense/quota_query) and add found/miss_reason to its output schema; the mock returns found=false with no quota numbers for unknown IDs. - Teach the skill instructions (collect / call / respond nodes) that found=false or a miss_reason means no such employee: never show quota digits, never take a user-supplied name or ID as verified, and ask for the ID instead of guessing. - Add a harness tool-result rule generalizing the same contract beyond this SOP. - Tests for the mock miss contract, internal-service auth on the new route, and seeded tool/skill assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #257.
问题
expense.quota_query之前指向外部演示服务http://58.57.119.30:52008/api/mock/expense/quota_query,对任意employee_id都返回 HTTP 200 和total_quota=20000。于是对不存在的人(如「张三 / 工号 666」)也能报出「额度 20,000 CNY,剩余 20,000 CNY」,T L 侧再拼上用户自己输入的姓名与工号,看起来就像查到了真实员工。根因有三层:
output_schema缺found/miss_reason,即便换成真实后端,对未知工号返回默认额度也会同样播报。改动
expense.quota_query的output_schema增加found、miss_reason(以及employee_name/department),并把 URL 指向仓库内 mock/api/mock/expense/quota_query,不再依赖外部演示地址。backend/app/api/mock.py新增/expense/quota_query,内置小规模花名册(E1001/E1002/E1003)。未知工号返回found=false+miss_reason=employee_not_found,且不包含任何额度数字;与同文件_order_miss/_product_miss语义一致。skills/skill_versions/agent_skill_branches/agent_skill_branch_versions四处同步更新):node_collect_info:姓名不能替代工号,仅提供姓名时必须追问工号,不得猜测或用示例工号代替。node_call_quota_query:found=false/miss_reason表示系统没有该工号,直接进入最终回复,不用相同工号重试,也不改用猜测工号。node_response_result:先检查found;found=false时明确告知未找到该员工,不得展示任何额度数字,且不得把用户提供的姓名/工号当作已核实信息。backend/app/llm/prompts/harness_agent_prompt.md):工具结果中出现found=false/miss_reason表示未命中而非成功,不得把默认额度、占位标识符(UNKNOWN等)或用户自行提供的标识符当作已核实事实对外展示。tests/test_mock_expense_quota_query.py:命中、裸数字工号归一、未知工号 miss、缺工号 miss、月份默认。tests/test_mock_auth.py:新增路由走内部服务鉴权;通过 HTTP 校验未知工号返回found=false且无额度字段。tests/test_staffdeck_seed.py:seed 后工具 URL 指向本地 mock、schema 含found/miss_reason、SOP 指令包含未命中处理。复现验证
请求本地 mock(内部服务鉴权后):
注意:需要重启开发环境以重新 seed(
scripts/dev_up.sh --detach),数据库会以 seed-managed 方式把工具 URL 与 SOP 内容更新到现有行。测试
pytest tests/test_mock_auth.py tests/test_mock_expense_quota_query.py tests/test_staffdeck_seed.py tests/test_chat_trace.py✅ 58 passedpytest tests:2060 passed,11 failed —— 与本次无关的环境预存失败,全部集中在test_channel_scope.py/test_feishu_schema_migration.py/test_feishu_durable_inbox.py/test_channel_team_binding.py,在干净 base(未含本次改动)上同样失败。ruff check新增/改动文件:通过(mock.py 现存 4 处 B008 为改动前即存在的告警)。风险与说明
expense.quota_query从外部地址切换为本地 mock,演示环境不再依赖58.57.119.30的该接口;其余 10 个工具仍指向外部地址,未在本 PR 范围。found/miss_reason)保持不变。