-
Notifications
You must be signed in to change notification settings - Fork 100
feat(coder/modules/agentapi): add log snapshot capture on shutdown #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Captures the last 10 messages from AgentAPI when task workspaces stop, allowing users to view conversation history while the task is paused. The shutdown script fetches messages, builds a payload with last 10 messages, truncates to 64KB if needed (removes old messages first, then truncates content of the last message), and posts to the log snapshot endpoint. Gracefully handles non-task workspaces (skips), older Coder versions without the endpoint (logs and continues), and empty message sets. Enabled by default via task_log_snapshot variable. Task ID is automatically resolved from data.coder_task when available. Updates coder/internal#1257
d161230 to
d3e42b0
Compare
54b1c13 to
f72792c
Compare
|
Verified implementation against current It does require the following change to terraform template for docker containers, however: Otherwise the agent gets killed while executing the script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f72792ccbc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| data "coder_workspace_owner" "me" {} | ||
|
|
||
| data "coder_task" "me" {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump provider version for coder_task data source
This module now declares data "coder_task" "me" {} but still allows coder provider >= 2.12. Tasks usage elsewhere in the repo pins coder to >= 2.13 (see registry/coder-labs/templates/tasks-docker/main.tf) alongside coder_task, which suggests the data source was introduced after 2.12. If a user is still on 2.12 (currently permitted by this module), Terraform will error with an unknown data source. Consider bumping required_providers.coder.version to >= 2.13 (or gating the data source) so non-task users on 2.12 aren’t broken.
Useful? React with 👍 / 👎.
| if ! command_exists jq; then | ||
| echo "Warning: jq is not installed. Task log snapshot requires jq to capture conversation history." | ||
| echo "Install jq to enable log snapshot functionality when the workspace stops." | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the shutdown script will exit 1. I'm guessing that's OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exit 1. I would say it's fine. That error will also complain about jq not being installed.
Captures the last 10 messages from AgentAPI when task workspaces stop,
allowing users to view conversation history while the task is paused.
The shutdown script fetches messages, builds a payload with last 10
messages, truncates to 64KB if needed (removes old messages first, then
truncates content of the last message), and posts to the log snapshot
endpoint.
Gracefully handles non-task workspaces (skips), older Coder versions
without the endpoint (logs and continues), and empty message sets.
Enabled by default via task_log_snapshot variable. Task ID is
automatically resolved from data.coder_task when available.
Updates coder/internal#1257