Skip to content

Separate agent vs local commands with client-side handling and feedback#15

Merged
BukeLy merged 11 commits intomainfrom
copilot/add-command-whitelist-mechanism
Jan 9, 2026
Merged

Separate agent vs local commands with client-side handling and feedback#15
BukeLy merged 11 commits intomainfrom
copilot/add-command-whitelist-mechanism

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 7, 2026

Client was forwarding all slash commands to the Agent backend, including CLI-local commands that produce no backend output.

  • Agent vs Local command config: Replaced the whitelist with agent_commands and local_commands in agent-sdk-client/config.toml; added a local /help example response.
  • Config loading & validation: tomllib loader now parses agent/local sections with defensive logging for malformed entries.
  • Command routing: Producer/consumer route agent commands to the backend and handle local commands (and unknown ones) client-side with consistent feedback.
  • Parsing safety: Hardened command extraction to ignore bot suffixes and empty/malformed commands.
  • User feedback: Local handling replies inline with allowed/known command lists to avoid silent drops.
  • Tests: Added unit coverage for agent/local config parsing, command extraction/classification, and edge cases (invalid/missing config, non-string entries, None text).

Example:

[agent_commands]
commands = ["/custom-skill", "/hello-world"]

[local_commands]
help = "Hello World"
Original prompt

This section details on the original issue you should resolve

<issue_title>feat: Client端添加命令白名单机制</issue_title>
<issue_description>## 问题

当前所有命令都传递给了AgentContainer,但部分Claude Code内置命令(如/help, /context等)没有实际输出返回,因为这些命令只是展示页面或修改CLI状态.

解决方案

Client端添加命令白名单机制,只有白名单中的命令才会被传递给Agent后端.

设计理念

配置文件即代码 - 使用TOML配置文件管理白名单

实现方案

  1. agent-sdk-client/添加config.toml配置文件
  2. 配置文件定义允许传递给后端的命令白名单
  3. Agent侧添加自定义命令时,需要同步添加到白名单

配置示例

[white_list_commands]
# 只有这些命令会被传递给Agent后端
whitelist = [
    "/custom-skill",
    "/hello-world",
    # ... 其他自定义命令
]

预期行为

  • 白名单内的命令 → 传递给AgentContainer处理
  • 白名单外的命令 → Client本地处理或忽略</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits January 7, 2026 19:50
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add command whitelist mechanism to client Add client command whitelist filtering for Agent forwarding Jan 7, 2026
Copilot AI requested a review from BukeLy January 7, 2026 19:58
@BukeLy BukeLy requested a review from Copilot January 7, 2026 20:06
Copy link
Copy Markdown
Owner

@BukeLy BukeLy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不够Userfriendly,你只是阻拦Command,你没有给User任何反馈,而且没前向兼容,未来如果有部分的cmd要在client处理就不好设置了.

@BukeLy BukeLy review requested due to automatic review settings January 7, 2026 20:09
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 7, 2026

不够Userfriendly,你只是阻拦Command,你没有给User任何反馈,而且没前向兼容,未来如果有部分的cmd要在client处理就不好设置了.

Blocked slash commands are now handled locally: users receive an inline “Unsupported command” message (listing allowed commands when configured) instead of silent drops, and the local handler is centralized for future client-side command logic. Fixed in 5b17e43.

Copilot AI changed the title Add client command whitelist filtering for Agent forwarding Add client command whitelist filtering and local feedback for blocked commands Jan 7, 2026
Copilot AI requested a review from BukeLy January 7, 2026 20:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a client-side command whitelist mechanism to filter which slash commands are forwarded to the Agent backend. Commands not in the whitelist are handled locally with immediate user feedback, preventing silent drops of CLI-local commands like /help or /context that produce no backend output.

  • Introduced TOML-based configuration for declaring allowed slash commands
  • Added config loading with defensive error handling and validation
  • Implemented command gating in both producer (webhook handler) and consumer (SQS processor)
  • Added local user feedback for blocked commands with helpful error messages

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
agent-sdk-client/config.toml New TOML configuration file defining whitelist of commands to forward to backend
agent-sdk-client/config.py Added TOML loading, command extraction logic, and whitelist validation with is_command_allowed method
agent-sdk-client/handler.py Added _handle_local_command to provide immediate feedback for non-whitelisted commands before SQS queueing
agent-sdk-client/consumer.py Added defensive whitelist check in SQS consumer (redundant with producer check)
tests/test_command_whitelist.py Added unit tests for whitelist loading and command allow/deny decisions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BukeLy
Copy link
Copy Markdown
Owner

BukeLy commented Jan 9, 2026

@copilot apply changes based on the comments in this thread

@BukeLy BukeLy self-requested a review January 9, 2026 08:56
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@BukeLy BukeLy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前local cmd和agent cmd不够清晰.
应该不是WhiteList CMD的概念,应该是部分cmd是agent cmd部分是local cmd.
所以CONFIG配置文件修改一下,
1.修改原来的whitelist cmd改为agent cmd
2.添加一个新的章节[local_cmd]
3.修改handle_local_command,如comment提到的.
4.实现一个/help的local命令示例,输出Hello World.
5.整体CodeReview一下保持KISS原则.

Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 9, 2026

当前local cmd和agent cmd不够清晰.
应该不是WhiteList CMD的概念,应该是部分cmd是agent cmd部分是local cmd.
所以CONFIG配置文件修改一下,...

Switched config to separate agent/local commands, added local /help example, and updated handler/local command handling accordingly. (2175062)

Copilot AI changed the title Add client command whitelist filtering and local feedback for blocked commands Separate agent vs local commands with client-side handling and feedback Jan 9, 2026
Copilot AI requested a review from BukeLy January 9, 2026 09:16
@BukeLy BukeLy marked this pull request as ready for review January 9, 2026 09:29
@BukeLy BukeLy merged commit 29bcb05 into main Jan 9, 2026
@BukeLy BukeLy deleted the copilot/add-command-whitelist-mechanism branch January 9, 2026 09:29
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.

feat: Client端添加命令白名单机制

3 participants