feat: agent initial#626
Draft
garrappachc wants to merge 13 commits into
Draft
Conversation
- Agent core in src/agent/ (create-session, execute-query, system-prompt) - Discord plugin auto-loaded at startup; no-ops when keys are missing - CLI entrypoint at agent/cli.ts for local testing (pnpm agent:cli) - Admin panel shows agent enabled/disabled status with reasons - Per-guild agent channel selection via multi-select in Discord config - agent.channels configuration key stores enabled guild+channel pairs - Fix pre-existing bug in set-multi.ts (missing $set operator + events) - Requires ANTHROPIC_API_KEY env var and MessageContent/GuildMembers Discord intents Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Playwright test resultsDetails
|
Track Anthropic API token usage per day in MongoDB so the counter survives restarts. Expose an agent.daily_token_budget configuration key (null = unlimited); when the daily limit is reached the bot replies with a friendly message instead of calling the API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Store per-channel conversation history in the agent.sessions collection so sessions survive app restarts. History is loaded from DB on first message after startup and saved after each answer. Sessions expire automatically after 30 days of inactivity via a TTL index. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of one session per channel (which mixed all conversations), sessions are now scoped to: - A Discord thread: thread channel ID is the session key - A reply chain: the root message ID is the session key, tracked via an in-memory map of bot reply IDs → session key For threads, the enabled-channel check falls back to the parent channel ID so existing admin configuration still applies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After each normally-ended game the agent reviews player performance and adjusts skill values where the evidence clearly warrants it. The review runs as a scheduled task 3 minutes after game:ended (to allow logs.tf data to be fetched) and uses the logs stats (DPM/K-D for DPS, HPM/ubers for medic) when available, falling back to score-only when they are not. Changes are written to skillHistory with actor='bot'. A consolidated Discord embed is posted to the admin-notifications channel listing every adjustment with a one-sentence reasoning and an overall game summary. The feature is opt-in via the agent.skill_supervisor configuration key (boolean, default false). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ndler - Move chat system prompt to src/agent/prompts/chat.ts - Move skill review prompt and builder to src/agent/prompts/skill-review.ts - Extract shared tools to src/agent/tools.ts (queryTools, submitReviewTool) - Parameterize createSession with systemPrompt and tools instead of hardcoding - reviewGameSkills now uses createSession for consistency, returning JSON text - Replace void IIFE in discord agent plugin with named handleMessage function - Remove unused 'agent' script from package.json Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add IconRobot icon from Tabler Icons - Add Agent page under /admin/agent showing enabled/disabled status and configuration for skill_supervisor and daily_token_budget - Register Agent in admin sidebar navigation (Configuration section) - Remove AgentStatus from Discord page (moved to Agent page) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Opus 4.7 costs $5/MTok input and $25/MTok output. Link to official pricing page with inline examples for 10k and 1M tokens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Break the dense single line into three distinct items: description, rate, and a bulleted example list. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wraps the agent channels select in a disabled fieldset with reduced opacity and swaps the hint text to explain why it is unavailable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each ask appends { at, inputTokens, outputTokens } to the
tokenUsage array on the session document via $push.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
What the agent can do
Session scoping
Conversations are grouped into sessions so the agent retains context across follow-up questions:
Sessions are persisted in MongoDB (`agent.sessions` collection) and expire automatically after 30 days of inactivity.
Cost controls
Token usage (input + output) is tracked per day in MongoDB (`agent.tokenusage` collection) and survives app restarts. A configurable daily token budget can be set via the `agent.daily_token_budget` configuration key (integer, `null` = unlimited). When the daily limit is reached the bot replies with a friendly message instead of calling the API. Usage resets at midnight UTC.
Configuration required
Test plan
🤖 Generated with Claude Code