Skip to content

fix(android): persist connect-time agent args for stateless CLI commands#2728

Open
yuyutaotao wants to merge 1 commit into
mainfrom
claude/shrink-parameter-design-81vx1l
Open

fix(android): persist connect-time agent args for stateless CLI commands#2728
yuyutaotao wants to merge 1 commit into
mainfrom
claude/shrink-parameter-design-81vx1l

Conversation

@yuyutaotao

Copy link
Copy Markdown
Collaborator

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

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +153 to +155
reportSession.agentInitArgs = {
...behaviorArgs,
} as Record<string, unknown>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants