You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Agents - Agent is not created when confirm page shows RuleBot has been added to your workspace #93624
Version Number: 9.4.8-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#93466 Email or phone of affected tester (no customers):oidjnoisdjoisjiosjdio@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Workspace Settings
Action Performed:
Precondition:
Enable Rules in workspace settings.
Go to staging.new.expensify.com
Go to workspace settings > Rules.
Click Add Agent rule.
Enter anything > Save.
Dismiss the confirm modal.
Go to Account > Agents.
Wait for the agent to show up.
Delete the agent.
Go to workspace settings > Rules.
Delete the agent rule from Step 4.
Click Add Agent rule.
Enter anything > Save.
Dismiss the confirm modal.
Go to Account > Agents.
Expected Result:
New agent will be created because confirm modal shows "RuleBot has been added to your workspace!".
Actual Result:
New agent is not created when confirm modal shows "RuleBot has been added to your workspace!".
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Root Cause: Two separate things are conflated here, and the real fix is outside the App repo.
The "RuleBot has been added to your workspace!" modal is purely cosmetic and unconditional. In AddAgentRulePage.tsx:71 the modal is shown whenever isEmptyObject(policy?.rules?.agentRules) is true. It does not verify that a RuleBot agent was actually created — it just assumes "zero agent rules ⇒ this is the first rule ⇒ backend will create RuleBot."
The actual RuleBot agent creation is a backend side-effect of the ADD_POLICY_AGENT_RULE command. The App-side action addPolicyAgentRule in Rules.ts:329 only writes the rule to Onyx — it never touches the agent.
In the repro, the user deletes the RuleBot agent (step 8) and all agent rules (step 10). When they re-add a rule (step 12), agentRules is empty again, so the App re-shows the "RuleBot has been added" modal — but the backend does not re-create the manually-deleted agent. The modal's claim is therefore false.
Why this surfaced now: PR #93466 only added the (correct, by-design) modal. It did not introduce the "agent not re-created" behavior — that is a pre-existing gap in the backend ADD_POLICY_AGENT_RULE command. The PR simply made the gap visible by asserting success in the UI.
Recommended fix (backend — escalate to an internal engineer): The substantive fix lives in the backend command that handles agent-rule creation, not in App. The backend should ensure a RuleBot agent exists whenever a workspace has ≥1 agent rule (i.e. re-create it on rule add if it was deleted). An internal engineer with access to the backend repo needs to own this.
A secondary App-side hardening is possible — only show the modal when the agent was actually created — but the App currently has no signal for RuleBot's existence (the agents list at settings/agents is backed by separate data, and RuleBot does not appear anywhere in the policy object). So this would also require the backend to return whether the agent was created. The clean fix is backend-first.
Investigation details
Modal logic: AddAgentRulePage.tsx:68-108. isFirstRule is derived solely from isEmptyObject(policy?.rules?.agentRules).
Add action: Rules.ts:329-397 — optimistic/success/failure data only mutate rules.agentRules; no agent record.
Delete action: Rules.ts:468-531 — removes the rule from agentRules, leaving it empty after the last rule is deleted, which re-arms the isFirstRule heuristic.
RuleBot appears in App only as copy strings in AddAgentRulePage.tsx and the src/languages/*.ts files — the frontend holds no agent-existence state.
Alternative explanation considered: a stale agents list (agent created but UI not refreshed). Less likely given the reporter explicitly "waits for the agent to show up" successfully on the first pass but not the second, and the title frames it as "not created." Backend logs keyed on the workspace's policyID would confirm definitively whether the second ADD_POLICY_AGENT_RULE created an agent — the issue only provides a tester email, so identifiers for a log query weren't available here.
Confidence: Medium — the misleading-modal mechanism is confirmed in App code; the "agent not re-created" root cause is inferred from the symptom and lives in a backend repo not visible from App.
Next Steps:
This needs a backend change (outside Expensify/App) — please escalate to an internal engineer with access to the ADD_POLICY_AGENT_RULE command repo.
Reply with @MelvinBot <your feedback> to refine this analysis.
Activity
applause-bot commentedon Jun 15, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/60655daddfd30a3352ff08c7ce4ebd624b63317f15f57dcef1aa1a0587cdb845
melvin-bot commentedon Jun 15, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #93466
melvin-bot commentedon Jun 15, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Jun 15, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
MelvinBot commentedon Jun 15, 2026
Issue Analysis
Root Cause: Two separate things are conflated here, and the real fix is outside the App repo.
The "RuleBot has been added to your workspace!" modal is purely cosmetic and unconditional. In
AddAgentRulePage.tsx:71the modal is shown wheneverisEmptyObject(policy?.rules?.agentRules)is true. It does not verify that a RuleBot agent was actually created — it just assumes "zero agent rules ⇒ this is the first rule ⇒ backend will create RuleBot."The actual RuleBot agent creation is a backend side-effect of the
ADD_POLICY_AGENT_RULEcommand. The App-side actionaddPolicyAgentRuleinRules.ts:329only writes the rule to Onyx — it never touches the agent.In the repro, the user deletes the RuleBot agent (step 8) and all agent rules (step 10). When they re-add a rule (step 12),
agentRulesis empty again, so the App re-shows the "RuleBot has been added" modal — but the backend does not re-create the manually-deleted agent. The modal's claim is therefore false.Why this surfaced now: PR #93466 only added the (correct, by-design) modal. It did not introduce the "agent not re-created" behavior — that is a pre-existing gap in the backend
ADD_POLICY_AGENT_RULEcommand. The PR simply made the gap visible by asserting success in the UI.Recommended fix (backend — escalate to an internal engineer): The substantive fix lives in the backend command that handles agent-rule creation, not in App. The backend should ensure a RuleBot agent exists whenever a workspace has ≥1 agent rule (i.e. re-create it on rule add if it was deleted). An internal engineer with access to the backend repo needs to own this.
A secondary App-side hardening is possible — only show the modal when the agent was actually created — but the App currently has no signal for RuleBot's existence (the agents list at
settings/agentsis backed by separate data, andRuleBotdoes not appear anywhere in the policy object). So this would also require the backend to return whether the agent was created. The clean fix is backend-first.Investigation details
AddAgentRulePage.tsx:68-108.isFirstRuleis derived solely fromisEmptyObject(policy?.rules?.agentRules).Rules.ts:329-397— optimistic/success/failure data only mutaterules.agentRules; no agent record.Rules.ts:468-531— removes the rule fromagentRules, leaving it empty after the last rule is deleted, which re-arms theisFirstRuleheuristic.RuleBotappears in App only as copy strings inAddAgentRulePage.tsxand thesrc/languages/*.tsfiles — the frontend holds no agent-existence state.Alternative explanation considered: a stale agents list (agent created but UI not refreshed). Less likely given the reporter explicitly "waits for the agent to show up" successfully on the first pass but not the second, and the title frames it as "not created." Backend logs keyed on the workspace's policyID would confirm definitively whether the second
ADD_POLICY_AGENT_RULEcreated an agent — the issue only provides a tester email, so identifiers for a log query weren't available here.Confidence: Medium — the misleading-modal mechanism is confirmed in App code; the "agent not re-created" root cause is inferred from the symptom and lives in a backend repo not visible from App.
Next Steps:
Expensify/App) — please escalate to an internal engineer with access to theADD_POLICY_AGENT_RULEcommand repo.@MelvinBot <your feedback>to refine this analysis.NicolasBonet commentedon Jun 15, 2026
Handling in Auth, this is a backend issue
puneetlath commentedon Jun 18, 2026
The PR was reverted.
NicolasBonet commentedon Jun 30, 2026
@puneetlath seems like we can close this one per https://github.com/Expensify/Auth/pull/22451?
melvin-bot commentedon Jun 30, 2026
@puneetlath Whoops! This issue is 2 days overdue. Let's get this updated quick!
puneetlath commentedon Jul 1, 2026
Yep, this is done!