Skip to content

[codex] Fix chmod batch agent identity contract#420

Draft
shangguanxuan633-lab wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
shangguanxuan633-lab:codex/fix-chmod-batch-agent-env
Draft

[codex] Fix chmod batch agent identity contract#420
shangguanxuan633-lab wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
shangguanxuan633-lab:codex/fix-chmod-batch-agent-env

Conversation

@shangguanxuan633-lab
Copy link
Copy Markdown
Contributor

Background

PR #414 changed dws pat chmod batch plan/grant payloads to include agentCode. Shell verification against the real batch plan endpoint showed that the batch service rejects this as a forged identity field:

PAT_FORGED_IDENTITY_FIELD: PAT batch identity field 'agentCode' must be derived by gateway.

The correct contract is: DINGTALK_DWS_AGENTCODE is picked up by the CLI and made visible to the MCP call environment/header path; pat.batch_plan and pat.batch_grant must not carry agentCode in the tool arguments.

Changes

  • Remove agentCode from pat.batch_plan / pat.batch_grant arguments.
  • Keep canonical/legacy single-grant fallback behavior unchanged.
  • Extend chmod tests to assert batch plan/grant calls see the env value while their args omit the identity field.

Shell smoke

Built the PR binary locally as /tmp/dws-chmod-agentcode and checked:

  • env DINGTALK_DWS_AGENTCODE=qoderwork /tmp/dws-chmod-agentcode --dry-run pat chmod aitable.record:read calendar.event:read --grant-type once prints AgentCode: qoderwork.
  • env -u DINGTALK_DWS_AGENTCODE /tmp/dws-chmod-agentcode --dry-run pat chmod aitable.record:read calendar.event:read --grant-type once prints AgentCode: (server default).
  • env DINGTALK_DWS_AGENTCODE=envval /tmp/dws-chmod-agentcode --dry-run pat chmod aitable.record:read calendar.event:read --grant-type once --agentCode flagval prints AgentCode: flagval.
  • env DINGTALK_DWS_AGENTCODE=qoderwork /tmp/dws-chmod-agentcode --dry-run -f json pat chmod --products calendar,aitable --grant-type once succeeds; summarized response: success=true agentCode=dingmbw5n9ktkkbbjv3g selected=0 skipped=32.

Verification

  • go test ./internal/pat
  • go test ./internal/app

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