Before a browser agent changes a setting or submits a record, it should verify the signed-in identity, active organization, environment and target object. A familiar logo or page title is not enough. Many applications let one person access several workspaces, and the same browser can retain a valid session for the wrong one.
Make account verification part of the action itself. Read the visible account and workspace state, compare it with the authorized target, then check again when navigation or reauthentication may have changed it. This guide explains that boundary and proposes a test plan using controlled accounts. It does not claim that browser isolation alone provides application authorization or protects every possible workflow.
- 01Check every relevant layerIdentity, organization, environment and object are separate targets.
- 02Isolation is not authorizationA separate context can still contain the wrong saved account state.
- 03Recheck meaningful transitionsSign-in, workspace switching and redirects can change the target.
- 04Verify the destinationA success message is weaker evidence than the saved object's state.
01 — IdentityName the intended account
A request should identify the account or organization where the work belongs whenever the application offers several plausible targets. Store the expected identity and organization as separate values. A user can be signed in with the correct email while viewing the wrong company workspace, so checking only the profile menu leaves an important ambiguity unresolved.
Use stable identifiers when the application exposes them, alongside human-readable names that the operator can recognize. Display names can be duplicated or changed. A workspace called “Production” is not sufficient if several organizations use that label. The agent should be able to explain which account and organization it verified before taking the consequential action.
Avoid deriving authority from access alone. A browser session may expose resources outside the user's requested scope. The task authorizes work on the specified target, not every resource the account can open. Our document-access guide applies the same distinction to retrieval: visibility and permission to use a resource for this task are related but separate questions.
- Record expected identity and organization separately.
- Treat accessible but unrequested resources as outside the task.
02 — ContextKeep the session boundary explicit
A browser context is a container for browser state. Playwright's isolation documentation describes contexts with separate cookies and local storage, similar to independent browsing profiles. This is useful for controlled tests and for keeping sessions apart, but it does not decide which application account a context should represent.
A newly created context can still be initialized with the wrong saved login state. A persistent profile can retain a workspace selected during an earlier task. Name or label the context for the intended purpose, then verify the application identity after it opens. The label is a routing aid for your automation, not evidence supplied by the application.
For a hypothetical agency workflow, keep the accounts used for separate clients in separate approved contexts where the tooling supports that separation. Still verify the active organization before editing a setting. Separation reduces accidental state sharing; it does not replace the target check. An operator can import the wrong session into a perfectly isolated context and make a cleanly isolated mistake.
| Layer | Evidence to inspect | What it cannot establish alone |
|---|---|---|
| Browser context | Which state container the agent controls | Correct application identity |
| Signed-in user | Account identity shown by the application | Correct organization or workspace |
| Organization | Active tenant or workspace identifier | Correct environment or target object |
| Action target | Record, project and environment in the current view | Authorization for unrelated resources |
03 — CredentialsTreat saved state as access
Saved authentication state can contain credentials sufficient to use an account. Playwright's authentication guidance warns that state files may contain sensitive cookies and headers and should not be committed to repositories. Treat these files as access material, not as harmless test fixtures or convenient debugging attachments.
Keep the storage location, access permissions and lifetime appropriate to the account. Logs should identify which test identity was used without printing session tokens. A screenshot or trace can also contain private account data, so scope what is retained and who can read it. The test record needs evidence of identity, not a copy of every credential that made the session work.
When a session expires, reauthenticate through the intended account flow and verify the resulting identity again. Do not assume a single sign-on screen returns to the same organization the agent previously used. An automatic account chooser can select a different profile, and the application may reopen a default workspace rather than the target from the original task.
A saved session is a way to obtain access. Its filename and the automation's label do not prove whose access it actually contains.
04 — NavigationRecheck after state-changing transitions
Not every page navigation needs a full identity review. Focus on transitions that can change the active account or workspace: sign-in, account switching, organization selection, opening a saved deep link or following a link into another administrative area. Define those checkpoints in the integration rather than relying on the model to remember an earlier observation indefinitely.
A deep link can be especially misleading. It may redirect to a default organization when the original target is unavailable, or open a similarly named project under the current session. Inspect the resolved page and target identifiers after the redirect. A successful page load establishes that something opened, not that it was the requested object.
Preserve useful progress while resolving a mismatch. The agent can prepare a proposed change from already authorized evidence, but it should stop the dependent write until the target is established. The principle in asking for missing information is to isolate the unresolved choice rather than restart the whole task or guess which account the user intended.
- Recheck identity after authentication and workspace changes.
- Verify the resolved target after redirects or deep links.
05 — PreviewBind approval to the current target
A reviewable change preview should name the organization, environment and object as well as the proposed values. “Enable the setting” is incomplete if the reviewer cannot see where it will be enabled. Show enough context for someone to recognize the intended target without exposing unnecessary private information.
Suppose an agent prepares a configuration change in a test project and the browser later switches to production. The values may be identical, but the action is different. Reusing the old approval would ignore the most consequential part of the change. Compare the current target with the preview immediately before execution and refresh the review when the organization, environment or object has changed.
This is the same contract described in previewing agent changes: approval covers a concrete proposal, not an unlimited category of future actions. Where the user has already authorized the exact operation, the system should proceed without redundant permission questions while still performing the target validation that makes the operation correct.
The reviewed target is still active
Confirm that the organization, environment and object match the accepted proposal, then execute and read back the result.
The target changed after review
Preserve the prepared work, identify the changed scope and obtain the missing decision if the existing authorization does not cover it.
06 — ConcurrencyAvoid shared session surprises
Two agents using the same persistent browser state can interfere with each other even when they are editing different objects. One may switch the organization or sign out while the other is preparing a write. Whether that state is shared across tabs depends on the application and browser behavior, so do not assume that a separate tab is a separate account boundary.
Use independent contexts or serialize account-sensitive work where the tooling allows it. If a shared session is unavoidable, define an owner for the active workflow and require a fresh target check before each consequential action. A lock around an automation process is not sufficient if a human or another tool can still change the browser state outside that lock.
Test the application behavior rather than relying on a general browser rule. In a controlled environment, switch workspaces in one tab and inspect the other before submitting anything. Record whether it updates, redirects or retains stale content. That observation helps you design the integration, but it should be tied to the tested application and version rather than presented as universal behavior.
A tab is a view, not necessarily an isolated session. Check what the application shares before allowing concurrent account-sensitive work.
07 — ReadbackVerify the resulting object
After an action, inspect the resulting object in the intended organization and environment. Compare the saved values with the accepted proposal and retain the relevant object reference. A success toast can be useful feedback, but it may not show which organization received the change or whether every field was applied as expected.
If the application navigates after saving, verify the destination rather than assuming it inherited the previous context. A new record might open in a global search view or an account-wide list. Use the object's identifier and ownership information where available. For a reversible setting change, capture enough before-and-after evidence to explain the actual delta without collecting unrelated account details.
An uncertain result requires reconciliation. If the browser loses its connection after submission, inspect the target state before repeating the action. The first operation may have completed. The same recovery boundary applies to agent form submissions: the workflow needs destination evidence, not just confidence that the click happened.
- Read back the saved object in the intended scope.
- Reconcile ambiguous outcomes before repeating a write.
08 — Test PlanExercise the wrong-account case
A controlled acceptance set should include the correct account in the wrong organization, an expired session, a redirect to a default workspace and a target whose display name matches another object. Use disposable records and approved test accounts. The test should fail safely before the write when the current target does not match the expected one.
Also test a session change between preview and execution. This exposes whether the application binds the final action to the reviewed target or merely remembers that an approval occurred earlier. Inspect the actual destination state after the test. A final assistant message saying it stopped is insufficient if the tool already submitted the change elsewhere.
For teams deploying browser agents through AI transformation, the useful outcome is a small, repeatable identity contract. Name the target, verify it at meaningful transitions, bind the write to it and read back the result. That foundation lets the agent act efficiently while keeping multi-account work understandable and recoverable.
- Test mismatches before testing large volumes of successful actions.
- Verify that a rejected target produces no unintended write.
Make account identity part of the action
Verify the intended identity and target at meaningful transitions, preserve session boundaries and compare the saved result with the accepted proposal. A browser agent should be able to show where it acted and what changed.