Skip to content

feat: add agentcore-cli User-Agent to all API calls#960

Open
notgitika wants to merge 1 commit intoaws:previewfrom
notgitika:feat/cli-user-agent-pr
Open

feat: add agentcore-cli User-Agent to all API calls#960
notgitika wants to merge 1 commit intoaws:previewfrom
notgitika:feat/cli-user-agent-pr

Conversation

@notgitika
Copy link
Copy Markdown
Contributor

@notgitika notgitika commented Apr 24, 2026

Summary

Sends agentcore-cli/<version> on all API requests so the service can differentiate CLI vs console vs curl traffic.

  • agentcore-control.ts: customUserAgent on all BedrockAgentCoreControlClient instances (deploy, status, list)
  • agentcore.ts: customUserAgent on all BedrockAgentCoreClient instances (invoke, evaluate, stop-session)

Test plan

  • npm run typecheck passes
  • All hooks pass

@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Apr 24, 2026
@notgitika notgitika force-pushed the feat/cli-user-agent-pr branch from 223b6cd to 39e1108 Compare April 24, 2026 20:02
@jesseturner21
Copy link
Copy Markdown
Contributor

Base branch mismatch — PR would regress version on preview

This PR targets preview, but the branch contains 7 commits that were merged to main (not preview) plus the actual User-Agent commit:

223b6cd feat: add agentcore-cli User-Agent to all API calls    ← the actual change
933bac8 fix: use pull_request_target for fork PR support (#958)
5271f55 fix: agentcore dev not working in windows (#951)
c30ed54 fix: add TTY detection before TUI fallbacks (#949)
3d2d671 fix: allow code-based evaluators in online eval configs (#947)
cb1e81a fix: buffer streaming text for GH Actions logs (#946)
a365bf5 feat: add GitHub Action for automated PR review (#934)
12275c3 chore: bump version to 0.10.0 (#944)

As a result, the diff against preview is ~1171 lines of changes (most of which have nothing to do with User-Agent), and merging would:

  • Downgrade the version from 1.0.0-preview.1 to 0.10.0 (preview is currently at 1.0.0-preview.1, main is at 0.9.1; this PR's package.json says 0.10.0).
  • Bring in changes that were only ever reviewed/merged against main, not preview.

Options

  1. Retarget this PR to main, which should make the diff shrink to just the two files in src/cli/aws/ (the branch is already based on recent main-equivalent history).
  2. Rebase the branch onto preview so only the User-Agent commit remains, then keep the base as preview.

Option 1 is probably the cleanest since the branch already lines up with main.

@jesseturner21
Copy link
Copy Markdown
Contributor

User-Agent coverage is incomplete

The PR description says:

  • agentcore-control.ts: customUserAgent on all BedrockAgentCoreControlClient instances
  • agentcore.ts: customUserAgent on all BedrockAgentCoreClient instances

But grep -rn 'new BedrockAgentCore' src/ turns up 8 other client instantiations that were not updated:

src/cli/aws/policy-generation.ts:36          new BedrockAgentCoreControlClient
src/cli/aws/policy-generation.ts:60          new BedrockAgentCoreControlClient
src/cli/operations/memory/list-memory-records.ts:36       new BedrockAgentCoreClient
src/cli/operations/memory/retrieve-memory-records.ts:31   new BedrockAgentCoreClient
src/cli/operations/deploy/pre-deploy-identity.ts:65       new BedrockAgentCoreControlClient
src/cli/operations/deploy/pre-deploy-identity.ts:107      new BedrockAgentCoreControlClient
src/cli/operations/deploy/pre-deploy-identity.ts:298      new BedrockAgentCoreControlClient
src/cli/operations/deploy/gateway-status.ts:32            new BedrockAgentCoreControlClient

These cover real user-invoked API surface (agentcore add policy, memory record listing/retrieval, agentcore deploy identity setup, gateway status polling), so calls from those flows will still look like plain SDK traffic to the service and defeat the goal of distinguishing CLI traffic.

Options

  1. Add customUserAgent to each of the 8 missed call sites (straightforward but repetitive).
  2. Introduce small factory helpers — e.g. createControlClient(region) / createAgentCoreClient(region) in src/cli/aws/ that set customUserAgent once — and route all callers through them. agentcore-control.ts already has a createControlClient helper; the other files could import it instead of calling new BedrockAgentCoreControlClient directly. This avoids the same gap recurring the next time someone adds a new call site.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Apr 24, 2026
@notgitika
Copy link
Copy Markdown
Contributor Author

updating the missed call sites using option 2

@notgitika notgitika force-pushed the feat/cli-user-agent-pr branch from 39e1108 to 4851166 Compare April 24, 2026 20:06
export async function startPolicyGeneration(
options: StartPolicyGenerationOptions
): Promise<StartPolicyGenerationResult> {
const client = new BedrockAgentCoreControlClient({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for updating this to use the shared helper!

Comment thread src/cli/aws/agentcore.ts
}

function createAgentCoreClient(region: string, headers?: Record<string, string>): BedrockAgentCoreClient {
export function createAgentCoreClient(region: string, headers?: Record<string, string>): BedrockAgentCoreClient {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not related to this change, but I wonder if we should cache the client for potential connection re-use.

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.

3 participants