Improve handler shape validation guidance#101
Merged
simongdavies merged 2 commits intomainfrom May 3, 2026
Merged
Conversation
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
0dc252c to
ea24aef
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the handler-shape validation and user guidance around register_handler by loosening parameter requirements (custom parameter names / no parameter) and providing clearer remediation messaging for common invalid handler forms (notably arrow handlers).
Changes:
- Extend JS validation to (a) treat plain
function handler(...) {}declarations as “module mode”, (b) allow handlers with custom/zero parameters, and (c) provide more targeted structure error guidance. - Add/expand test coverage for the updated validator behavior (TS-side analysis guest tests + sandbox tool execution tests).
- Update agent-facing guidance (system message + tool/help text) to reflect the supported handler shapes and common invalid patterns.
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 |
|---|---|
| tests/sandbox-tool.test.ts | Adds execution tests for module handlers with custom parameter names and with no parameters. |
| tests/analysis-guest.test.ts | Adds validator tests for module-mode detection, allowed signatures, and improved guidance for invalid handler shapes. |
| src/code-validator/guest/runtime/src/validator.rs | Implements signature-issue detection, updates module-mode detection, and adjusts handler structure validation messaging. |
| src/agent/system-message.ts | Updates the “mandatory handler format” guidance to mention async-only-with-await, flexible params, and arrow-handler rejection. |
| src/agent/index.ts | Updates tool/help text for register_handler and handler guidance to align with the validator’s rules. |
…sistency
- Gate return-check on has_handler_function && no signature issue to
avoid misleading 'MUST return' errors on invalid handler shapes
- Expand check_handler_has_return skip logic to also skip arrow function
bodies (=> { ... }) and generator declarations (function*)
- Fix conflicting guidance in register_handler tool description: use
function handler(...) instead of function handler(event) in REQUIRED line
- Add zero-parameter form function handler() to system-message signature list
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.