feat(tfe): add list_run_comments tool (#347)#352
Open
ChrisJr404 wants to merge 2 commits into
Open
Conversation
Closes the read-side gap on the run-comment surface. `action_run`
already lets agents post a comment when applying / discarding /
canceling a run, but until now there was no way to read the existing
comments back: an agent inspecting a run via `get_run_details` could
see that comments existed (the workspace comment ID is returned) but
couldn't retrieve their bodies, which limits its ability to act on
context left by humans or other automation.
The new tool wraps the existing TFE Comments API endpoint
(`GET /runs/{run_id}/comments`) via go-tfe's Comments.List. It takes
a single required `run_id`, returns each comment's id and body in a
RunCommentList projection, and follows the same shape conventions as
list_runs:
- read-only annotation (WithReadOnlyHintAnnotation true)
- non-destructive annotation
- structured RunCommentSummary / RunCommentList types so future
field additions (resolved-by, created-at) are passthrough
Wired through the standard places — toolsets/mapping.go for toolset
gating, tools/dynamic_tool.go for the conditional registration on
the Terraform toolset.
No pagination today because the upstream Comments.List endpoint
returns the full list in one response (the go-tfe CommentList
type embeds *Pagination but the endpoint doesn't actually populate
page cursors). Wrapping in a struct anyway so it stays
forward-compatible if pagination is later wired up.
go build ./... → clean
go vet ./... → clean
go test ./pkg/tools/tfe/... ./pkg/toolsets/... → ok
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.
Closes #347.
`action_run` already lets agents post a run comment when applying / discarding / canceling, but there was no way to read the existing comments back. `get_run_details` returns the comment ID, but no body — so an agent inspecting a run can see that humans left context but can't act on it.
This wires the existing TFE Comments API (`GET /runs/{run_id}/comments`, surfaced via `go-tfe`'s `Comments.List`) as a new `list_run_comments` tool. Shape mirrors `list_runs`:
```json
// list_run_comments({"run_id": "run-CZcmD7eagjhyX0vN"})
{
"items": [
{"id": "comment-XXX", "body": "Approved by @sre, retrying after the 503"},
{"id": "comment-YYY", "body": "..."}
]
}
```
Wiring
Three files:
What's not in scope
Test plan
Note on duplication
@vavdoshka offered on the issue to contribute this — happy to defer if they were already partway through. Didn't see an open PR or a draft branch from them, so I went ahead. If you'd rather their PR land instead, totally fine to close this one.