feat(agent-cli): validate tool input against the declared schema - #1924
feat(agent-cli): validate tool input against the declared schema#1924ScriptedAlchemy wants to merge 6 commits into
Conversation
Both tool executors now check each invocation's input against the tool's declared inputSchema before dispatch and throw a ToolInputValidationError listing every mismatch, instead of forwarding unchecked input to handlers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rsdoctor/agent-cli
@rsdoctor/cli
@rsdoctor/client
@rsdoctor/core
@rsdoctor/shared
commit: |
Deploying rsdoctor-v1 with
|
| Latest commit: |
760f88e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://539a4bc5.rsdoctor-v1.pages.dev |
| Branch Preview URL: | https://codex-agent-cli-input-valida.rsdoctor-v1.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9844ebd305
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds executor-side input validation for @rsdoctor/agent-cli tools, ensuring tool invocations are checked against their declared inputSchema before dispatch and surfacing structured validation errors to programmatic consumers.
Changes:
- Introduces
validateToolInput+ToolInputValidationErrorto validate tool inputs and report aggregated issues. - Hooks validation into both the spawned-CLI and in-process tool executors.
- Adds comprehensive unit tests covering validation success/failure cases across both executor paths and exports validation utilities from the package entry.
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 |
|---|---|
| packages/agent-cli/src/core/validate-input.ts | Implements schema-based input validation and a structured error type. |
| packages/agent-cli/src/executor.ts | Validates tool input before dispatch for both executor implementations. |
| packages/agent-cli/src/commands/router.ts | Ensures in-process tool entries carry the same inputSchema as the catalog. |
| packages/agent-cli/src/index.ts | Exposes validation exports from the package public API. |
| packages/agent-cli/tests/tool-input-validation.test.ts | Adds tests for validation behavior (types, required, bounds, enums, arrays, aggregation, both executors). |
Suppressed comments (2)
packages/agent-cli/src/core/validate-input.ts:74
- Similar to
integer,numbervalidation currently rejects numeric strings, which makes validation stricter than CLI/control parsing and can break programmatic callers that pass stringified numbers (common when values originate from argv/env/JSON).
case 'number':
return typeof value === 'number' && Number.isFinite(value);
packages/agent-cli/src/core/validate-input.ts:145
- Numeric bounds (
minimum/maximum) are only enforced when the value is a JSnumber. If numeric strings are accepted forinteger/number(as per CLI/control parsing), bounds should be checked against the coerced numeric value as well; otherwise values like'5000'would bypassmaximumchecks.
if (typeof value === 'number') {
if (typeof schema.minimum === 'number' && value < schema.minimum) {
issues.push({
path,
message: `${label} must be >= ${schema.minimum}, received ${value}`,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ontract' into codex/agent-cli-input-validation # Conflicts: # packages/agent-cli/src/commands/router.ts # packages/agent-cli/src/core/result-controls.ts
Deploying rsdoctor with
|
| Latest commit: |
760f88e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e8f9be91.rsdoctor.pages.dev |
| Branch Preview URL: | https://codex-agent-cli-input-valida.rsdoctor.pages.dev |
…ontract' into codex/agent-cli-input-validation
…ontract' into codex/agent-cli-input-validation
Summary
Both tool executors (
createRsdoctorCliToolExecutorandcreateInProcessRsdoctorCliToolExecutor) validate each invocation against the tool's declared JSON Schema before dispatch, throwing a structuredToolInputValidationErrorinstead of forwarding unchecked input to handlers.page,pageNumber,pageSize, andlimitcontrols.pageNumberandlimitremain supported aliases and are normalized before handler dispatch.{ path, message }issues and prevent the command from running.ToolInputValidationErroris exported for programmatic consumers.This PR is intentionally stacked on the artifact and bounded-output work in #1903 so its pkg.pr.new preview represents the exact contract consumed by Rstack Context.
Verification
Related Links