fix(android): persist connect-time agent args for stateless CLI commands#2728
fix(android): persist connect-time agent args for stateless CLI commands#2728yuyutaotao wants to merge 1 commit into
Conversation
CLI commands run in separate, stateless processes, so agent behavior options (e.g. screenshotShrinkFactor) passed only to `connect` were lost on the following `act`/`tap` process, which rebuilt the agent without them. As a result `--screenshot-shrink-factor` set at connect time had no effect on `act`, keeping token usage at the unshrunk level. Persist the agent behavior args into the CLI report session at `connect` and merge them back in `ensureAgent` so a later command inherits them. Command-provided args still take priority. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B2U6dXW6An9rxzpSTd6fhM
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b72061fcac
ℹ️ 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".
| reportSession.agentInitArgs = { | ||
| ...behaviorArgs, | ||
| } as Record<string, unknown>; |
There was a problem hiding this comment.
Persist the connected device for stateless Android commands
When midscene-android connect --device-id X --screenshot-shrink-factor 2 is followed by a stateless act/tap without repeating --device-id, this writes only behavior args into the session. ensureAgent() then rebuilds with deviceId still undefined, so on machines with multiple ADB devices the follow-up command can run against whichever device auto-detect returns instead of the device the user just connected to, while still using that device's report session/options.
Useful? React with 👍 / 👎.
CLI commands run in separate, stateless processes, so agent behavior
options (e.g. screenshotShrinkFactor) passed only to
connectwere loston the following
act/tapprocess, which rebuilt the agent withoutthem. As a result
--screenshot-shrink-factorset at connect time had noeffect on
act, keeping token usage at the unshrunk level.Persist the agent behavior args into the CLI report session at
connectand merge them back in
ensureAgentso a later command inherits them.Command-provided args still take priority.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01B2U6dXW6An9rxzpSTd6fhM