Skip to content

feat(logging): add detailed logging support to the CLI - #1745

Merged
Hweinstock merged 20 commits into
aws:refactorfrom
Hweinstock:feat/logging
Jul 14, 2026
Merged

feat(logging): add detailed logging support to the CLI#1745
Hweinstock merged 20 commits into
aws:refactorfrom
Hweinstock:feat/logging

Conversation

@Hweinstock

@Hweinstock Hweinstock commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Direct port of AlexanderRichey/agentcore-cli#3.

Problem

The CLI is currently doesn't log detailed information for debugging purposes.

Solution

  • leverage pino to wrap detailed logs to files in .agentcore/logs/.
  • use a "rolling" logger such that old logs are automatically overwritten to avoid unbounded space consumption.
  • add withLogging middleware to inject this logger into each command handler with command path metadata.

Note: these are structured JSON logs that accept arbitrary bindings.

Examples:

 {
   "level": "debug",
   "time": 1783642477147,
   "cliSessionId": "261f5986-a1ab-4cc8-87e7-24a5d45a07cb",
   "commandPath": "/agentcore/config",
   "flags": {},
   "args": {},
   "msg": "executing command"
 }
 {
   "level": "debug",
   "time": 1783642477148,
   "cliSessionId": "261f5986-a1ab-4cc8-87e7-24a5d45a07cb",
   "commandPath": "/agentcore/config",
   "msg": "command executed successfully"
 }
 {
   "level": "debug",
   "time": 1783642767760,
   "cliSessionId": "313df3a4-a963-437e-bb4c-56f9ce0d47c8",
   "commandPath": "/agentcore/harness/get",
   "flags": { "id": "fake" },
   "args": {},
   "msg": "executing command"
 }
 
 {
   "level": "error",
   "time": 1783642767771,
   "cliSessionId": "313df3a4-a963-437e-bb4c-56f9ce0d47c8",
   "commandPath": "/agentcore/harness/get",
   "errorName": "CredentialsProviderError",
   "errorMessage": "Could not load credentials from any providers",
   "stack": "CredentialsProviderError: Could not load credentials from any providers\n    at ...",
   "msg": "command failed"
 }
 
 {
   "level": "error",
   "time": 1783642767771,
   "cliSessionId": "313df3a4-a963-437e-bb4c-56f9ce0d47c8",
   "errorName": "CredentialsProviderError",
   "errorMessage": "Could not load credentials from any providers",
   "stack": "CredentialsProviderError: Could not load credentials from any providers\n    at ...",
   "msg": ""
 }

Testing

  • add unit tests at the middleware level to test real commands on a test application.
  • test output e2e via test command.

Notes

  • potential alternative of winston over pino: this PR leverages pino because it supports structured logs natively, written in TS so has native type support, and is overall a simpler logging solution.
  • there are likely more places we can add logging, but the code is changing fast, and don't want to add noise. This PR is focused on setting up the structure for logging.
  • Many tests are failing (this is pre-existing on upstream).
  • tsc is also failing (pre-existing on upstream).

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jul 13, 2026
@Hweinstock

Hweinstock commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Harness reviewer is failing with

Run actions/setup-python@v6
Installed versions
  Version 3.12 was not found in the local cache
  Error: The version '3.12' with architecture 'x64' was not found for amzn 2023.
  The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json

This looks like a bug related to codebuild migration where python version is not available. I also see the same issue in:
https://github.com/aws/agentcore-cli/actions/runs/29121238023/job/86456628695?pr=1739 (an earlier PR). Filed an issue for this: #1746.

Unsure on what the codebuild job is doing here, I don't see any workflows with that name https://github.com/aws/agentcore-cli/tree/main/.github/workflows. @notgitika do you have an idea of where is this coming from?

@Hweinstock
Hweinstock marked this pull request as ready for review July 13, 2026 15:08
@avi-alpert

Copy link
Copy Markdown
Contributor

The .tsx file extension should only be used with files with JSX, in my experience it helps to know at a glance which files contain components and which are utils/logic.

const commandPath = ctx.require(PathKey);
const logger = config.logger.child({ commandPath });
try {
logger.child({ flags, args }).debug("executing command");

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.

do we redact any sensitive values used in args? like in agentcore add credential

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we currently do not, but we'll definitely want to once we have sensitive data coming through here. I think this makes the most sense to address when we start introducing relevant functionality.

Let me add a comment here to help avoid missing this on future implementations.

@Hweinstock

Copy link
Copy Markdown
Contributor Author

The .tsx file extension should only be used with files with JSX, in my experience it helps to know at a glance which files contain components and which are utils/logic.

I think this makes sense. I created a backlog issue to migrate this: #1755.

@Hweinstock
Hweinstock merged commit aae8c4b into aws:refactor Jul 14, 2026
@Hweinstock
Hweinstock deleted the feat/logging branch July 14, 2026 18:52
This was referenced Sep 3, 2026
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