Skip to content

Add receipt-bound Feishu approvals with repairable Tool feedback - #965

Draft
Y1fe1Zh0u wants to merge 3 commits into
dataelement:mainfrom
Y1fe1Zh0u:feature/feishu-reimbursement-tools
Draft

Add receipt-bound Feishu approvals with repairable Tool feedback#965
Y1fe1Zh0u wants to merge 3 commits into
dataelement:mainfrom
Y1fe1Zh0u:feature/feishu-reimbursement-tools

Conversation

@Y1fe1Zh0u

@Y1fe1Zh0u Y1fe1Zh0u commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add typed Feishu approval definition, attachment upload, and approval creation tools
  • bind approval submission to the exact tenant, applicant, Run, Tool Ledger receipt, and in-chat confirmation
  • preserve human mentions in native group replies without creating child Runs for humans
  • keep mixed human and Agent mention validation atomic while handing work only to wakeable Agents
  • remove provider-incompatible anyOf, oneOf, and allOf from model-visible Tool schemas while retaining the constraints in handlers
  • preserve bounded, sanitized Feishu provider receipts so approval failures expose actionable HTTP and business error details
  • validate approval attachment/image values as non-empty arrays of file-code strings before confirmation

Why

Feishu approval creation is an external write and must not be authorized by a stale or reusable confirmation. The approval tools therefore bind consent and provider submission to the current conversation, Runtime execution, tenant roster, applicant, and Tool receipt.

Two follow-up problems are addressed in the same branch:

  1. Group Runtime preflight rejected every non-Agent mention even though native group delivery already supports visible human mentions.
  2. Some model providers reject composite Tool schemas before execution, while generic Feishu rejection summaries hide the receipt needed to repair invalid requests.

The resulting contract keeps public mention targets separate from wakeable Agent targets, and keeps model-visible schemas compatible without weakening execution-time validation.

Validation

  • latest local integration run: 390 passed across scoped Runtime, group handoff, finish protocol, Tool outcome, deployment, image, Vercel, Feishu approval, and builtin Tool contract tests
  • the initial approval-tool commit records 335 relevant backend tests, scoped Ruff, compileall, diff check, and independent review/verification
  • Ruff passed for the 11 changed Tool/test files outside agent_tools.py
  • full-file Ruff on agent_tools.py remains blocked by 56 pre-existing findings outside the changed regions

Not tested

  • live Feishu approval creation
  • external model-provider schema acceptance
  • browser rendering and live 3010 mixed-mention E2E

Add typed Feishu approval definition, attachment upload, and create tools while binding provider submission to the exact tenant, Run, Tool Ledger receipt, applicant, and in-chat confirmation.

Constraint: Approval creation must not depend on a new frontend or legacy ApprovalRequest flow
Constraint: Existing user worktree changes remain outside this commit
Rejected: Bare yes/no confirmation | stale replies could authorize another request
Rejected: Raw approver and CC open IDs | bypasses tenant roster authorization
Rejected: Reusable bearer proof | could replay an identical provider write
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Do not expose feishu_approval_create outside the receipt-bound Durable Runtime conversation gate
Tested: 335 relevant backend tests; scoped Ruff; compileall; diff check; independent code review and verification
Not-tested: Live Feishu Provider create and 3010 deployment
Native group replies already persist human mentions without dispatching work, but the Runtime at preflight rejected every non-Agent participant. Split public mention validation from Agent handoff validation so mixed human and Agent targets remain atomic while child Runs are created only for wakeable Agents.

Constraint: Human mentions must remain visible without creating child Runs.

Rejected: Strip human IDs during model repair | loses structured mention metadata and contradicts group message behavior.

Confidence: high

Scope-risk: narrow

Directive: Keep public mention targets distinct from wakeable Agent targets.

Tested: 232 scoped Runtime and group delivery tests; Ruff check on changed files.

Not-tested: Browser rendering and live 3010 mixed-mention E2E pending deployment.
Some model providers reject composite Tool schemas before execution, while generic Feishu approval failures hide the receipt needed to correct a request. Keep model-visible schemas provider-compatible, enforce composite constraints in handlers, and preserve bounded sanitized Feishu receipts through Runtime outcome storage.

Constraint: Model-visible Tool schemas must avoid anyOf, oneOf, and allOf for provider compatibility
Rejected: Drop conditional argument constraints | handlers still need to reject invalid calls
Rejected: Persist raw provider responses without bounds | response bodies may be large or contain secrets
Confidence: high
Scope-risk: moderate
Directive: Keep composite constraints in handlers when simplifying model-visible schemas
Tested: 290 scoped pytest cases passed; Ruff passed on 11 files and the changed agent_tools.py regions had no reported violations
Not-tested: Live Feishu approval calls and external model-provider acceptance
@Y1fe1Zh0u Y1fe1Zh0u changed the title Stabilize Tool repair feedback and mixed group mentions Add receipt-bound Feishu approvals with repairable Tool feedback Aug 14, 2026
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.

1 participant