fix(discord): auto presence health signal#33277
Conversation
Greptile SummaryThis PR adds auto-presence and connected-state health monitoring to the Discord provider. The implementation is functionally sound:
Minor documentation gap: The Confidence Score: 4/5
Last reviewed commit: e6dbd1f |
| - `autoPresence.healthyText` | ||
| - `autoPresence.degradedText` | ||
| - `autoPresence.exhaustedText` (supports `{reason}` placeholder) |
There was a problem hiding this comment.
The code in resolvePresenceActivities calls renderTemplate(template, { reason: reasonLabel }) for the degraded state as well (line 174), so autoPresence.degradedText supports the {reason} placeholder too. The docs currently only mention this template capability for exhaustedText.
| - `autoPresence.healthyText` | |
| - `autoPresence.degradedText` | |
| - `autoPresence.exhaustedText` (supports `{reason}` placeholder) | |
| - `autoPresence.healthyText` | |
| - `autoPresence.degradedText` (supports `{reason}` placeholder) | |
| - `autoPresence.exhaustedText` (supports `{reason}` placeholder) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/channels/discord.md
Line: 858-860
Comment:
The code in `resolvePresenceActivities` calls `renderTemplate(template, { reason: reasonLabel })` for the `degraded` state as well (line 174), so `autoPresence.degradedText` supports the `{reason}` placeholder too. The docs currently only mention this template capability for `exhaustedText`.
```suggestion
- `autoPresence.healthyText`
- `autoPresence.degradedText` (supports `{reason}` placeholder)
- `autoPresence.exhaustedText` (supports `{reason}` placeholder)
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e6dbd1fb27
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (profileIds.length === 0) { | ||
| return { state: "degraded", unavailableReason: null }; |
There was a problem hiding this comment.
Handle empty auth store without forcing degraded presence
When channels.discord.autoPresence.enabled is on and auth-profiles.json has no entries, resolveAuthAvailability always returns degraded, so Discord status stays idle even if the runtime is actually healthy (for example, env/config-backed provider credentials or local models). This conflicts with runtime fallback behavior, which only treats a provider as unavailable when profiles exist and all are in cooldown (src/agents/model-fallback.ts checks profileIds.length > 0 && !isAnyProfileAvailable). As written, many valid setups will report permanent degradation.
Useful? React with 👍 / 👎.
src/discord/monitor/provider.ts
Outdated
| const botIdentity = | ||
| botUserId && botUserName ? `${botUserId} (${botUserName})` : (botUserId ?? botUserName ?? ""); | ||
| runtime.log?.(`logged in to discord${botIdentity ? ` as ${botIdentity}` : ""}`); | ||
| opts.setStatus?.({ connected: true }); |
There was a problem hiding this comment.
Report connected only after gateway connectivity is confirmed
This sets connected: true before any confirmed gateway connection event, so startup paths where REST identity fetch fails or websocket connect never succeeds can still be reported as connected until some later lifecycle patch arrives. In those cases, operators and health tooling get a false healthy signal. The connected=true update should come from the existing lifecycle connection callbacks that observe actual gateway connectivity.
Useful? React with 👍 / 👎.
|
Thanks for consolidating this work 🙏 One important gap: this PR currently does not include the Discord self-profile update scope from #33202. In #33202, there is a separate, security-scoped feature for Discord-only self updates:
Why self-profile update is needed
Without
So these are complementary scopes:
Could we either:
I’m happy to help split this cleanly if preferred. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1596941fcb
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (profileIds.length === 0) { | ||
| return { state: "degraded", unavailableReason: null }; |
There was a problem hiding this comment.
Treat empty auth stores as healthy availability
When auto presence is enabled, this branch forces state: "degraded" whenever auth-profiles.json has no entries, so setups that use env/config credentials without auth profiles will remain idle even while requests succeed. Fresh evidence: runWithModelFallback only marks provider availability as failed when profileIds.length > 0 and all profiles are in cooldown, so this logic diverges from the runtime failover path and reports a persistent false-degraded status.
Useful? React with 👍 / 👎.
1596941 to
4ab3bbd
Compare
|
Landed via temp rebase onto main.
Thanks @thewilloftheshadow! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ab3bbd7e7
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const hasUsableProfile = profileIds.some( | ||
| (profileId) => !isProfileInCooldown(params.store, profileId, params.now), | ||
| ); |
There was a problem hiding this comment.
Restrict availability check to runtime-eligible profiles
This marks Discord auto-presence as healthy when any auth profile is usable, even if that profile is for an unrelated provider that the current runtime/model path cannot use. In mixed-profile setups (for example, OpenAI model in cooldown plus an unused Anthropic key), status will stay online while requests fail, because resolveAuthAvailability only checks Object.keys(store.profiles) here, whereas fallback execution is provider-scoped (src/agents/model-fallback.ts computes profileIds per candidate provider before deciding availability). This mismatch can hide real outages from operators.
Useful? React with 👍 / 👎.
Summary
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
channels.discord.autoPresenceconfiguration to map runtime availability to Discord presence (online/idle/dnd) with optional status text overrides.connectedtrue on login and false on shutdown for health monitoring.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
channels.discord.autoPresence.enabled=true.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Compatibility / Migration
Backward compatible? (
Yes)Config/env changes? (
Yes)Migration needed? (
No)If yes, exact upgrade steps:
channels.discord.autoPresence.enabled=true.Failure Recovery (if this breaks)
channels.discord.autoPresence.enabled=falseRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.