feat: add temporary ID support to add_comment tool#19737
Conversation
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Update item_number schema to accept strings (temporary IDs) in addition to numbers - Add temporary_id field to add_comment tool schema - Fix 'silently discarded' description inaccuracy -> 'fail with an error' - Update addCommentHandler to auto-generate and return temporary_id - Fix randomBytes(6) -> randomBytes(4) to stay within 8-char schema limit - Add tests for new temporary_id behavior in handlers and MCP constraints Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed issue #19734 in commit
Also fixed a pre-existing bug in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…dCommentHandler Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| }, | ||
| "temporary_id": { | ||
| "type": "string", | ||
| "pattern": "^aw_[A-Za-z0-9]{3,8}$", |
There was a problem hiding this comment.
@copilot review if pattern is compatible with other temporary_id patterns. see how other safe outputs handle it.
There was a problem hiding this comment.
Updated in commit 578bca7. All temporary_id patterns across both schema files (create_issue, add_comment, create_project, update_project) now use {3,12}, consistent with the isTemporaryId() regex in temporary_id.cjs. Descriptions updated to say "3 to 12 alphanumeric characters" accordingly.
…Id in temporary_id.cjs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class temporary ID support to the add_comment safe output tool so agents can (a) target newly-created items via temporary IDs and (b) receive a temporary_id back from the MCP handler for later reference.
Changes:
- Update
add_comment.item_numberschema to acceptnumber | string(temporary IDs) and clarify failure behavior when auto-targeting is unavailable. - Add
temporary_idto theadd_commenttool schema and implement auto-generation + return oftemporary_idinaddCommentHandler. - Update/extend tests and regenerate workflow lock schemas to reflect the new schema shape.
Reviewed changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/js/safe_outputs_tools.json | Expands add_comment schema (string item_number, new temporary_id, updated description). |
| actions/setup/js/safe_outputs_tools.json | Mirrors add_comment schema updates for the action runtime. |
| actions/setup/js/safe_outputs_handlers.cjs | Implements addCommentHandler temporary ID generation/validation and returns it in the MCP response. |
| actions/setup/js/safe_outputs_mcp_add_comment_constraints.test.cjs | Adds constraint tests asserting temporary_id is persisted and returned. |
| actions/setup/js/safe_outputs_handlers.test.cjs | Adds unit tests for addCommentHandler response structure and NDJSON recording. |
| .github/workflows/workflow-health-manager.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/unbloat-docs.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/technical-doc-writer.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/sub-issue-closer.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-workflow-call.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-update-cross-repo-pr.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-test-tools.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-temporary-id.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-project.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-multi-pr.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-gemini.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-create-cross-repo-pr.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-copilot.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-copilot-arm.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-codex.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-claude.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/smoke-agent.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/security-alert-burndown.campaign.g.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/scout.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/refiner.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/q.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/pr-triage-agent.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/poem-bot.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/pdf-summary.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/issue-triage-agent.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/issue-monster.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/draft-pr-cleanup.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/discussion-task-miner.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/dev-hawk.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/daily-fact.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/daily-cli-performance.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/daily-assign-issue-to-user.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/craft.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/contribution-check.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/cloclo.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/ci-doctor.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/brave.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/archie.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
| .github/workflows/agent-performance-analyzer.lock.yml | Regenerated tool schema snapshot to reflect new add_comment fields/types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| "temporary_id": { | ||
| "type": "string", | ||
| "pattern": "^aw_[A-Za-z0-9]{3,12}$", | ||
| "description": "Unique temporary identifier for this comment. Format: 'aw_' followed by 3 to 12 alphanumeric characters (e.g., 'aw_abc1', 'aw_Test123'). Auto-generated if not provided. The temporary ID is returned in the tool response so you can reference this comment later." |
There was a problem hiding this comment.
Same issue as in pkg/workflow/js/safe_outputs_tools.json: temporary_id pattern/description restricts to 3–8 chars, but the helper validation supports 3–12 and tests expect 3–12. This inconsistency can reject otherwise-valid temporary IDs. Align this schema to 3–12 (and ideally mention lowercase normalization in the description).
| const { ERR_CONFIG, ERR_SYSTEM, ERR_VALIDATION } = require("./error_codes.cjs"); | ||
| const { findRepoCheckout } = require("./find_repo_checkout.cjs"); | ||
| const { resolveTargetRepoConfig, resolveAndValidateRepo } = require("./repo_helpers.cjs"); | ||
| const { generateTemporaryId, getOrGenerateTemporaryId } = require("./temporary_id.cjs"); |
There was a problem hiding this comment.
generateTemporaryId is imported but never used in this file. Either remove it from the require() or use it directly; leaving unused imports makes future refactors noisier and can trigger lint failures if/when linting is enabled.
| const addCommentHandler = args => { | ||
| // Validate comment constraints before appending to safe outputs |
There was a problem hiding this comment.
addCommentHandler assumes args is always defined (it later reads args.body). A malformed tool call with missing arguments can throw a TypeError and surface a confusing error message. Consider guarding access (e.g., treat missing args as {} and explicitly validate body) so failures consistently return a clear JSON-RPC -32602 "Invalid params" error.
All items from issue #19734 are addressed across commits
|
|
@copilot apply changes based on the comments in this thread |
…mmentHandler Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Applied all changes from the review thread in commit
The pattern mismatch items (3–8 vs 3–12) were already fixed in |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready. |
Agent Container Tool Check
Result: 12/12 tools available ✅ Overall Status: PASS
|
Smoke Test: Copilot - 22748465795
Overall: PASS (Serena MCP not configured in this environment)
|
There was a problem hiding this comment.
This PR extends temporary_id support to add_comment and broadens the pattern from {3,8} to {3,12} characters. The changes enable more flexible cross-referencing between safe-output operations. The refactoring to use getOrGenerateTemporaryId centralizes validation logic cleanly. Looks good!
📰 BREAKING: Report filed by Smoke Copilot
| }; | ||
| }; | ||
|
|
||
| return { |
There was a problem hiding this comment.
The addCommentHandler now returns temporary_id to the agent - great improvement for enabling cross-reference workflows where agents need to reply to or update a previously posted comment.
| entry.temporary_id = tempIdResult.temporaryId; | ||
| server.debug(`temporary_id for create_project: ${entry.temporary_id}`); | ||
|
|
||
| // Append to safe outputs |
There was a problem hiding this comment.
Using getOrGenerateTemporaryId helper is a good refactor — it centralizes validation logic and ensures consistent error codes (-32602) across all handlers that use temporary IDs.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
Smoke Test Results — Run §22748465797 Core tests #1-10: PR review tests #11-17: Overall: PARTIAL (1 skipped, 16/17 passed)
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal! This review was generated by smoke test run 22748465797 to validate the PR review submission workflow.
💥 [THE END] — Illustrated by Smoke Claude
add_commenttool description: inaccurate "silently discarded" behavior and missing temporary_id guidance #19734 and understand current add_comment temporary ID supportitem_numberschema type to accept both numbers and strings (temporary IDs)temporary_idfield toadd_commenttool schemasafe_outputs_handlers.cjsto auto-generate and returntemporary_idforadd_commentgenerateTemporaryIdandgetOrGenerateTemporaryIdhelpers fromtemporary_id.cjsin bothcreateProjectHandlerandaddCommentHandler(replaces inlinecrypto.randomBytes)generateTemporaryId()temporary_idschema patterns from{3,8}to{3,12}to matchisTemporaryId()validation intemporary_id.cjsgenerateTemporaryIdimport fromsafe_outputs_handlers.cjsargsaccess inaddCommentHandlerto handle missing arguments gracefullytemporary_id.cjstoSAFE_OUTPUTS_FILESinsetup.sh(fixes CI test failure insetup_sh_file_lists.test.cjs)Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
✨ PR Review Safe Output Test - Run 22748465797