[$175] Agents - "It´s not here" page displayed after saving and reopening custom instructions.
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.5.42-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/107100 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome App Component: Other
Action Performed:
Prerequisite: Use a fresh account.
- Open the staging.new.expensify.com website.
- Navigate to "Account" > "Agents" > "New Agent"
- Click on "Build custom agent" > "Create Agent"
- Close chat RHP.
- Before agent´s owner column appears on preview, click on row to open the edit RHP.
- Click on "Write custom instructions"
- Save instructions and reopen them.
- Note that you land on "It´s not here" page after reopening custom instructions.
Expected Result:
User should be able to reopen agent´s custom instructions after saving them.
Actual Result:
User lands on "It´s not here" page after saving agent´s custom instructions and reopening them.
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/d57544f4-9440-49f8-ad75-678ab359692b
Applause Internal Information Exported by: Chandana Kiran Bug ID: 7318437
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022123218654483112391
- Upwork Job ID: 2123218654483112391
- Last Price Increase: 2026-11-19
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/b223d21c460a7fd9d54221b8bb7143b6d5bf449e7e767b9fa507cac19f5be38f
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (External)
Job added to Upwork: https://www.upwork.com/jobs/~022123218654483112391
Proposal
What is the root cause of that problem?
Likely cause — medium confidence: opening the agent before creation finishes exposes an account-ID type mismatch. Creation updates the open editor with a number, while dynamic URL parsing produces a string. Saving instructions can therefore replace the instructions screen with a second editor instead of returning to the existing editor. Reopening instructions then generates an invalid nested URL and reaches “It’s not here.”
This mechanism is supported by code, but the exact timing-dependent failure was not reproduced.
Code evidence and alternatives checked
- Reconciliation updates mounted routes with numeric IDs: replaceOptimisticAgentWithActualAgent.ts:62–76.
- Dynamic parsing bypasses configured parameter conversion: getStateFromPath.ts:45–55.
- Back-navigation compares route parameters and falls back to replacement when the parent does not match: Navigation.ts:363–403, Navigation.ts:614–620.
- Duplicate editors serialize into repeated edit segments, which violate the permitted route hierarchy: getPathFromState.ts:165–189, ROUTES.ts:2366–2379.
An ordinary save failure is a weaker explanation: it rolls back instructions rather than deleting the agent (Agent.ts:283–311).
What changes do you think we should make in order to solve the problem?
Normalize agent editor route IDs consistently to numbers during dynamic parsing, honoring their configured parser. Avoid weakening global navigation comparisons or merely hiding the error.
Add a navigation regression test that opens a pending agent, completes creation, saves instructions, and reopens them. Assert that Save returns to the original editor and the URL contains only one agent-edit segment. This should also confirm the proposed mechanism before implementation is accepted.
What alternative solutions did you explore? (Optional)
Stringifying IDs during reconciliation would address navigation matching, but conflicts with numeric route declarations and mapping lookups. Disabling editing until creation completes would mask the inconsistency.
Possibly related: Agent — “Hmm... it’s not here” when quickly opening Edit Agent after creation. It shares the timing prerequisite, but is not confirmed as the same failure.
Web verification
🤖 Web test steps verification results: ⚠️ partial
Saved instructions reopened successfully after the owner appeared. The required before-owner timing could not be achieved; supported testing controls could not delay creation.
| Step | Status |
|---|---|
| Open app with fresh account | ✅ |
| Account > Agents > New agent | ✅ |
| Build custom agent > Create agent | ✅ |
| Close chat RHP | ✅ |
| Open before owner appears | ⚠️ |
| Write custom instructions after owner appears | ✅ |
| Save and reopen | ✅ |
| Confirm saved text reopens without not-found | ✅ |
| Delay creation and inspect runtime parameter types | ⚠️ |
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/107338) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a custom agent, opens its edit RHP (Settings_Agents_Dynamic_Edit) before CreateAgent finishes reconciling (i.e., before the owner column appears), saves custom instructions (Settings_Agents_Dynamic_Edit_Prompt), and then clicks Write custom instructions a second time, the app navigates to the "It's not here" (NotFoundPage) screen instead of reopening the instructions editor.
What is the root cause of that problem?
config.ts declares parse: {accountID: Number} on all four dynamic agent edit screens (SCREENS.SETTINGS.AGENTS.DYNAMIC_EDIT, DYNAMIC_EDIT_NAME, DYNAMIC_EDIT_PROMPT, and DYNAMIC_EDIT_AVATAR at src/libs/Navigation/linkingConfig/config.ts:340-363, matching AccountSettingsParamList.ts:248-259), and createNormalizedConfigs.ts:104 already stores parse on every entry in normalizedConfigs.
However, getStateForDynamicRoute (src/libs/Navigation/helpers/dynamicRoutesUtils/getStateForDynamicRoute.ts:49-83) only reads config.routeNames from normalizedConfigs and completely ignores config.parse:
- Before
CreateAgentfinishes, clicking the optimistic agent row navigates to/settings/agents/<optimisticID>/edit.findAllMatchingDynamicSuffixesextractspathParams = {accountID: "<optimisticID>"}as a rawstring, andgetStateForDynamicRoutemountsDYNAMIC_EDITwithparams: {accountID: "<optimisticID>"}(string). - When
CreateAgentresolves while the editor (orDYNAMIC_EDIT_PROMPT) is mounted,redirectAgentSettingsScreens(src/libs/actions/replaceOptimisticAgentWithActualAgent.ts:52-74) comparesNumber(route.params.accountID) === optimisticAccountIDand callsNavigation.setParams({accountID: realAccountID}, route.key, state?.key), mutating the mountedDYNAMIC_EDITroute'sparams.accountIDto anumber(realAccountID). - When the user clicks Save in
DynamicEditPromptPage(src/pages/settings/Agents/Fields/DynamicEditPromptPage.tsx:72),Navigation.goBack(backPath)callsgoUp('/settings/agents/<realID>/edit')(src/libs/Navigation/Navigation.ts:518-625):getStateFromPath(backToRoute)parses/settings/agents/<realID>/editviagetStateForDynamicRoute, producing a target payload withparams: {accountID: "<realID>"}(string) becauseconfig.parsewas skipped.doesRouteMatchToMinimalActionPayload(Navigation.ts:375-404) compares the mountedDYNAMIC_EDITroute ({accountID: 88442211}) againstminimalActionParams({accountID: "88442211"}) viashallowCompare(===), which returnsfalse(88442211 !== "88442211").- Because
findRouteToPopTofails (canPopToRoute === false),Navigation.ts:616-619dispatchesREPLACEinstead ofPOP, replacingDYNAMIC_EDIT_PROMPTon top of the stack with a secondDYNAMIC_EDITscreen ([DYNAMIC_EDIT(number), DYNAMIC_EDIT(string)]).
- When the user clicks "Write custom instructions" again,
getPathFromStateWithDynamicRoute(src/libs/Navigation/helpers/getPathFromState.ts:154-208) serializes both stackedDYNAMIC_EDITroutes into/settings/agents/<realID>/edit/<realID>/edit, socreateDynamicRoute(DYNAMIC_ROUTES.AGENT_EDIT_PROMPT.getRoute())navigates to/settings/agents/<realID>/edit/<realID>/edit/prompt.getStateFromPathstrips/promptand recursively parses/settings/agents/<realID>/edit/<realID>/edit: its outer:accountID/editsuffix seesfocusedRoute.name === SCREENS.SETTINGS.AGENTS.DYNAMIC_EDIT, which failsDYNAMIC_ROUTES.AGENT_EDIT.entryScreens([SCREENS.SETTINGS.AGENTS.ROOT, SCREENS.WORKSPACE.AGENTS]atsrc/ROUTES.ts:2369), falling through toSCREENS.NOT_FOUND("It's not here").
(Note: this also confirms why DYNAMIC_PROFILE at ProfilePage.tsx:311 (/a/:accountID/prompt) must remain unaffected: SCREENS.DYNAMIC_PROFILE intentionally has no parse in config.ts (ProfileNavigatorParamList expects accountID: string), whereas DYNAMIC_EDIT_PROMPT has parse: {accountID: Number}. Applying each dynamic route's own config.parse in getStateForDynamicRoute keeps DYNAMIC_PROFILE params as string so goBack('/a/<accountID>') still matches DYNAMIC_PROFILE, while converting DYNAMIC_EDIT / DYNAMIC_EDIT_PROMPT / DYNAMIC_EDIT_NAME / DYNAMIC_EDIT_AVATAR accountID to number.)
What changes do you think we should make in order to solve the problem?
- Honor
RouteConfig['parse']insidegetStateForDynamicRoute(src/libs/Navigation/helpers/dynamicRoutesUtils/getStateForDynamicRoute.ts):- Update
getRouteNamesForDynamicRoute(renamed togetRouteConfigForDynamicRoute) to return the matchedRouteConfig({routeNames, parse}) fromnormalizedConfigsinstead of onlyconfig.routeNames. - When building the leaf route's
cleanedParams(lines 72-75), applymatchedConfig.parseto any string-valued param whose key has a parser function inmatchedConfig.parse:function applyRouteParamParsers(params: Record<string, unknown>, parseConfig: RouteConfig['parse']): Record<string, unknown> { if (!parseConfig) { return params; } const parsedParams = {...params}; for (const [key, parser] of Object.entries(parseConfig)) { if (typeof parser === 'function' && Object.hasOwn(parsedParams, key) && typeof parsedParams[key] === 'string') { parsedParams[key] = parser(parsedParams[key]); } } return parsedParams; } - This guarantees
DYNAMIC_EDIT,DYNAMIC_EDIT_NAME,DYNAMIC_EDIT_PROMPT, andDYNAMIC_EDIT_AVATARalways holdaccountID: number(matchingAccountSettingsParamList,RNGetStateFromPath, andreplaceOptimisticAgentWithActualAgent), while routes withoutparse(such asSCREENS.DYNAMIC_PROFILE) retainstringparams untouched.
- Update
- Add unit and navigation regression tests:
- In
tests/navigation/getStateForDynamicRouteTests.ts: verify that dynamic routes withparseinnormalizedConfigsconvert string path/parent params (e.g.accountID: Number), skip already-parsed non-string values, and leave routes withoutparse(DYNAMIC_PROFILE) as strings. - In
tests/navigation/GoBackTests.tsx(andtests/actions/ReplaceOptimisticAgentWithActualAgentTest.ts): cover openingDYNAMIC_EDITwith an optimistic agent ID, reconciling viareplaceOptimisticAgentWithActualAgent, openingDYNAMIC_EDIT_PROMPT, callingNavigation.goBack(backPath), and reopeningDYNAMIC_EDIT_PROMPT— asserting the stack pops back to the singleDYNAMIC_EDITinstance (/settings/agents/<realID>/edit) and reopens/settings/agents/<realID>/edit/promptwithout hittingSCREENS.NOT_FOUND.
- In
What alternative solutions did you explore? (Optional)
- Passing
String(realAccountID)inreplaceOptimisticAgentWithActualAgent.ts: ViolatesAccountSettingsParamList(accountID: number), diverges from cold-startRNGetStateFromPathbehavior (config.tsparse: {accountID: Number}), and leaves runtime param types inconsistent with TypeScript definitions. - Coercing numbers to strings inside
Navigation.ts(doesRouteMatchToMinimalActionPayload): Weakens route parameter matching globally across all navigators instead of fixing the missingconfig.parsestep ingetStateForDynamicRoute.
@rojiphil I tested this on the latest main (da1f0beb17d) to check MelvinBot's medium-confidence root cause, and it's correct.
Repro (web): I opened the pending agent's edit RHP, then simulated the CreateAgent response arriving late.
- After Save, the URL becomes
/settings/agents/<id>/edit/<id>/edit. - Reopening the instructions goes to
/not-found("Hmm... it's not here").
The open editor gets accountID as a number from setParams, but dynamic route parsing returns a string. goUp's === comparison misses, and the REPLACE that follows stacks a second editor.
Fix: I applied MelvinBot's approach (honor the screen's parse config in getStateForDynamicRoute). Save now returns to a single editor, and the instructions reopen with the saved text.
- Only 4 of 332 dynamic routes declare
parse, all of them agent edit screens, so the change stays scoped to them./a/:accountIDstill gets a string. - The Agent name page has the same bug, and this fix covers it too.
- A new navigation test fails on
main(3 of 4 cases) and passes with the fix. All 159 navigation and agent suites still pass.
I think MelvinBot's proposal is the right fix here.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Proposal
Fix the agent custom-instructions "It's not here" page by making dynamic URL parsing honor the linking config's parse functions, so a route param resolved from a URL has the same type as the same param set by navigation code. The change is one helper in one file, plus six new regression tests.
Branch: fix-107338-agent-instructions-not-found (base e91964cbf8f2032a8679573d629c831238d4632d).
Please re-state the problem that we are trying to solve in this issue.
Create a new agent, open its custom-instructions editor before creation finishes, save the instructions, then reopen them. Instead of the editor with the saved text, the app shows the "It's not here" page.
The bug only bites when agent creation completes between opening the editor and saving. If creation finishes before the editor opens, or is still running when the save happens, the flow works. That timing condition is why the repro is flaky and why an earlier verification attempt could not reproduce it.
What is the root cause of that problem?
The root cause is an accountID type mismatch between two ways the same edit route gets its params, and the mismatch breaks the save-time back navigation.
- Dynamic URL parsing returns params as strings.
getStateFromPathextracts path params asRecord<string, string>andgetStateForDynamicRoutemerges them into the leaf route without ever applying the linking config'sparsefunctions, even though the config declaresaccountID: Numberfor all four agent edit screens (src/libs/Navigation/linkingConfig/config.ts). - Reconciliation writes a number. When creation completes,
replaceOptimisticAgentWithActualAgentredirects the open edit route withNavigation.setParams({accountID: realAccountID}), a number. From that moment the mounted edit route holds a number while any URL-parsed route holds the same digits as a string. - Save goes back by path, and the comparison misses. Saving calls
Navigation.goBack(backPath).goUpparses that back path (string params) and compares it withshallowCompare(strict===) against the mounted edit route (number params). The comparison fails, sogoUptakes its REPLACE fallback instead of popping: the prompt route is replaced in place by a second edit route, leaving two edit routes in the RHP stack. - The doubled stack serializes to a doubled URL.
getPathFromStateturns the two edit routes into/settings/agents/<id>/edit/<id>/edit. Reopening instructions appends/promptto it, and parsing that URL fails the AGENT_EDIT entry-screens check (DYNAMIC_EDIT is not an allowed entry screen), so it resolves toSCREENS.NOT_FOUND, which renders "It's not here". - The same mismatch has a second consequence, scoped to URL-parsed entries. A save issued while the prompt screen still holds a string optimistic ID calls
resolveAgentAccountID(string), which misses the number-keyed in-memory mapping (src/libs/AgentAccountIDMapping.ts), so the prompt write lands on the optimistic key and is wiped when the reconciler clears the optimistic agent. The in-app navigate path already passes numeric IDs, so the string case only arises when the screen's params came from URL parsing (deep link or restored state). This is fixed at the same parser boundary and covered by a direct test; the reconciler-cleanup interplay itself is covered by the existingReplaceOptimisticAgentWithActualAgentTest.
What changes do you think we should make in order to solve the problem?
Apply the leaf screen's configured parse functions to string-valued merged params when building the leaf route in src/libs/Navigation/helpers/dynamicRoutesUtils/getStateForDynamicRoute.ts (new applyConfiguredParse helper, +27/-1). Only string values are converted, so params already resolved to their converted type keep it. This is the single choke point for path-parsed dynamic routes: getStateFromPath is the only caller. It is not a claim about every route-param source in the app; in-memory state, Navigation.navigate, setParams, and hydrated state are unaffected.
Blast radius, verified by enumerating all 329 dynamic routes: only the four agent edit screens (DYNAMIC_EDIT, DYNAMIC_EDIT_NAME, DYNAMIC_EDIT_PROMPT, DYNAMIC_EDIT_AVATAR) have a parse config anywhere in their route chain, and in each case the parse lives only on the leaf screen (accountID: Number), so leaf-only parsing is sufficient and no ancestor parse can be missed. The other parse configs in the linking config (rules tag index, subscription canChangeSize, merchant orderWeight, reportID) belong to static routes handled by React Navigation's own parser and are untouched by this change.
Deliberately not changed: the global shallowCompare/goBack comparison, the reconciler's numeric setParams, and resolveAgentAccountID.
Tests (new file tests/navigation/AgentEditPromptNavigationTest.ts, 6 tests):
- Dynamic parsing returns the accountID as a number, for all four agent edit screens. Fails on baseline, passes after the fix.
- The save-time goBack action matches the reconciled prompt state, so goBack pops instead of replacing. Fails on baseline, passes after the fix.
- Unreconciled control: the same goBack action matches when nothing was reconciled yet. Passes on both, which pins why the bug needs the reconciliation timing.
- A stack with two edit routes serializes to the doubled edit segment. Passes on both, characterizing the malformed URL.
- A URL-parsed optimistic accountID resolves to the real one through
resolveAgentAccountIDafter the mapping is registered. Fails on baseline, passes after the fix. - The doubled prompt URL resolves to the not-found screen. Passes on both, characterizing the reported symptom.
Related suites, all green after the fix: 14 suites, 150 tests (getStateFromPathTests, dynamicSettingsRhpBackgroundTests, getDynamicRouteAdaptedStateTests, cardAuthenticationDynamicRouteTests, holdReasonDynamicRouteParamsTest, ReplaceOptimisticAgentWithActualAgentTest, EditPromptPageTest, EditAgentPageTest, EditNamePageTest, getAdaptedStateFromPathTabStripTests, linkingConfigColdStartTests, getMatchingFullScreenRouteTests, getPathWithoutDynamicSuffixTests, betaOverridesDynamicRouteTest). Repo lint passes on both changed files and cspell reports 0 issues.
Honest gaps: no real-device run (jest only), and the full typecheck was skipped because it runs out of memory on the 6 GB machine used for this prep; it should run in CI. The fix itself is type-safe by construction (it only converts string values through the config's own parse functions), and the new tests use no type assertions.
What alternative solutions did you explore? (Optional)
- Loosen
shallowCompareor thegoBackcomparison so string and number params match. Rejected: it would weaken route identity globally and hide real type drift instead of fixing it. - Make the reconciler set a string accountID so both sides stay strings. Rejected: it would encode the parser bug into the reconciler instead of fixing the parser.
- Make
resolveAgentAccountIDaccept strings. At most defense-in-depth, not a primary fix: it would not solve the duplicate-route and malformed-path chain that produces the Not Found page, and no string source remains from URL parsing once this fix lands. - Disable editing until agent creation completes. Rejected: it masks the inconsistency and makes the UI worse for a bug with a one-line root cause.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@rojiphil Huh... This is 4 days overdue. Who can take care of this?
@rojiphil 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
@rojiphil 10 days overdue. I'm getting more depressed than Marvin.