refactor: clean CLI taxonomy — canonical subcommands, merged memory.update, no aliases
- calendar: split write → create/read/update/delete/share - contacts: rename lookup → read - memory: merge write+forget → update (unified action field in operations) - Remove all alias/normalization logic from adapter and handlers - Update tool_postprocessor ui_hints builders to canonical keys - Remove frontend legacy TOOL_CALL_START/ARGS/END events and ToolCallItem - Update SKILL.md files and protocol docs - Update tests and settings screens
This commit is contained in:
@@ -404,3 +404,7 @@ Do not mark an item complete until the code, docs, and verification for that ite
|
||||
- [x] Phase 3 complete
|
||||
- [x] Phase 4 complete
|
||||
- [x] Phase 5 complete
|
||||
- [x] 2026-04-23: finished frontend cleanup for legacy tool-call interim events/cards; tool UI render path is now `TOOL_CALL_RESULT` + history replay only
|
||||
- [x] 2026-04-23: documented `messages.content` decision to remain `text` (structured payload stays in metadata)
|
||||
- [x] 2026-04-23: removed CLI alias compatibility and switched to canonical subcommands (`calendar.create/read/update/delete/share`, `contacts.read`, `memory.update`)
|
||||
- [x] 2026-04-23: expanded protocol and postprocessor policy so canonical CRUD commands emit `ui_hints` (`calendar.create/read/update/delete`, `contacts.read`, `memory.update`)
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
# Debug Session: Tool Credential Injection Issue
|
||||
|
||||
## Date
|
||||
2026-04-22
|
||||
|
||||
## Context
|
||||
|
||||
After completing the skills+CLI refactor, running live integration tests revealed tool credential injection issues.
|
||||
|
||||
## Commits Made
|
||||
|
||||
1. `4d55df4` - refactor: unify skills+cli runtime and streamline ag-ui flow
|
||||
2. `ef931ee` - chore: clean up legacy tool/UI code paths and remove unused events
|
||||
3. `91077a9` - fix: pass tool_call_id to parse_tool_agent_output for proper payload resolution
|
||||
|
||||
## Test Execution
|
||||
|
||||
```bash
|
||||
CLI_SKILLS_LIVE_TEST=1 TEST_USER_ID="f6f4bc6b-f525-434e-81b6-38eeef9b89a8" \
|
||||
AGENT_LIVE_BASE_URL="http://localhost:5775" \
|
||||
uv run pytest backend/tests/integration/test_cli_skills_live.py::test_calendar_read_skill_queries_db -v -s
|
||||
```
|
||||
|
||||
## Error Found
|
||||
|
||||
From `logs/errors/worker-agent.error.log`:
|
||||
|
||||
```
|
||||
"error": "tool credential not found in runtime context",
|
||||
"tool_name": "project_cli"
|
||||
```
|
||||
|
||||
Full stack trace shows:
|
||||
1. `invoke_cli_tool` calls `_resolve_owner_id()`
|
||||
2. `_resolve_owner_id()` calls `get_tool_credential()`
|
||||
3. `get_tool_credential()` returns `None`
|
||||
4. Raises `TokenValidationError("tool credential not found in runtime context")`
|
||||
|
||||
## Root Cause Analysis
|
||||
|
||||
The tool credential is set via context variable `tool_credential` but is not being injected into the runtime context before tool execution.
|
||||
|
||||
### Key Files
|
||||
|
||||
- `backend/src/core/auth/tool_credential_context.py` - ContextVar for tool credential
|
||||
- `backend/src/core/agentscope/tools/cli/adapter.py` - Calls `get_tool_credential()`
|
||||
- `backend/src/core/agentscope/runtime/runner.py` - Should inject credential before tool execution
|
||||
|
||||
### Expected Flow
|
||||
|
||||
1. Runner receives run request with `owner_id`
|
||||
2. Runner creates tool credential using `ToolCredentialIssuer`
|
||||
3. Runner sets credential via `set_tool_credential(credential)`
|
||||
4. Tool execution reads via `get_tool_credential()`
|
||||
5. After execution, credential is cleared
|
||||
|
||||
### Missing Implementation
|
||||
|
||||
The credential injection logic needs to be added to `runner.py` around the worker stage execution.
|
||||
|
||||
## Secondary Error
|
||||
|
||||
When tool credential fails, the error response causes a DB insert error:
|
||||
|
||||
```
|
||||
invalid input for query argument $5: {'status': 'failure', ...} (expected str, got dict)
|
||||
```
|
||||
|
||||
This is because `content` field receives a dict instead of str. Fixed in `store.py` by ensuring proper serialization, but the root cause is the missing credential.
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. Find where tool credential should be set in runtime
|
||||
2. Add credential issuance in runner before tool execution
|
||||
3. Ensure credential is passed through task queue or generated in worker
|
||||
4. Restart backend service with new code
|
||||
5. Re-run integration tests
|
||||
|
||||
## Database State
|
||||
|
||||
- `system_agents.config.enabled_skills`: Correctly uses `["calendar", "contacts"]`
|
||||
- `automation_jobs.config`: No longer has `enabled_tools`
|
||||
- User ID for testing: `f6f4bc6b-f525-434e-81b6-38eeef9b89a8`
|
||||
|
||||
## Files Modified
|
||||
|
||||
- `backend/src/core/agentscope/runtime/stage_emitter.py` - Fixed `tool_call_id` passing
|
||||
- `backend/tests/integration/test_cli_skills_live.py` - Added live integration tests
|
||||
|
||||
## Remaining Work
|
||||
|
||||
- [ ] Fix tool credential injection in runtime
|
||||
- [ ] Verify calendar read/write works end-to-end
|
||||
- [ ] Verify contacts lookup works end-to-end
|
||||
- [ ] Verify memory write via automation works
|
||||
- [ ] Run full test suite after fixes
|
||||
@@ -14,23 +14,15 @@
|
||||
"branch": "worktree/refactor-tool-cli-skill-ui-schema",
|
||||
"base_branch": "dev",
|
||||
"worktree_path": ".worktrees/refactor-tool-cli-skill-ui-schema",
|
||||
"current_phase": 2,
|
||||
"current_phase": 5,
|
||||
"next_action": [
|
||||
{
|
||||
"phase": 1,
|
||||
"action": "implement"
|
||||
},
|
||||
{
|
||||
"phase": 2,
|
||||
"phase": 5,
|
||||
"action": "check"
|
||||
},
|
||||
{
|
||||
"phase": 3,
|
||||
"action": "finish"
|
||||
},
|
||||
{
|
||||
"phase": 4,
|
||||
"action": "create-pr"
|
||||
"phase": 5,
|
||||
"action": "implement"
|
||||
}
|
||||
],
|
||||
"commit": null,
|
||||
@@ -63,6 +55,14 @@
|
||||
{
|
||||
"name": "Verify end-to-end agent -> CLI -> UI flow",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"name": "Remove CLI alias compatibility and enforce canonical subcommands",
|
||||
"status": "completed"
|
||||
},
|
||||
{
|
||||
"name": "Expand ui_hints policy to canonical CRUD commands and refactor postprocessor framework",
|
||||
"status": "completed"
|
||||
}
|
||||
],
|
||||
"children": [],
|
||||
@@ -79,8 +79,8 @@
|
||||
"docs/protocols/ui/data-flow.md",
|
||||
"docs/protocols/agent/sse-events.md"
|
||||
],
|
||||
"notes": "Protocol docs must be updated before backend/frontend contract changes. Current implementation still compiles worker ui_hints into ui_schema and registers tools directly as Python functions.",
|
||||
"notes": "Core refactor is complete and protocol/docs/tests are aligned. CLI now uses canonical subcommands only (no alias compatibility). ui_hints policy follows canonical CRUD commands with a common postprocessor framework.",
|
||||
"meta": {
|
||||
"feature_summary": "tool refactor + CLI wrapping + skill guidance + tool-schema rendered UI + worker output simplification"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user