-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Improve agent logging #1486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve agent logging #1486
Conversation
🦋 Changeset detectedLatest commit: a01ddd0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
Greptile SummaryThis PR improves the user experience when an agent execution stops due to reaching the maximum step limit. Previously, users would only see Changes made:
The implementation correctly distinguishes between normal completion (when the agent calls the Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant AgentHandler
participant LLMClient
participant Logger
User->>AgentHandler: execute(instruction, maxSteps=2)
AgentHandler->>AgentHandler: prepareAgent()
AgentHandler->>LLMClient: generateText() with stopWhen
loop Each Step
LLMClient->>AgentHandler: onStepFinish(step)
AgentHandler->>Logger: Log step finished
end
LLMClient-->>AgentHandler: result (steps.length >= maxSteps)
AgentHandler->>AgentHandler: consolidateMetricsAndResult(result, maxSteps)
alt Max steps reached
AgentHandler->>AgentHandler: Check !completed && steps >= maxSteps
AgentHandler->>Logger: Log "Agent stopped: reached maximum steps (2)"
AgentHandler->>AgentHandler: Set finalMessage
else Normal completion
AgentHandler->>AgentHandler: Use collectedReasoning
end
AgentHandler-->>User: AgentResult {success: false, message: "Agent stopped...", completed: false}
|
Why
The agent currently provides no indication when it stops due to reaching the max step limit. Users see
success: falseandcompleted: falsebut have no way to distinguish between a max steps stop vs other failure scenarios.Additionally, tool logs display arguments as stringified JSON which is hard to read.
What Changed
Max steps indication:
Agent stopped: reached maximum steps (X)messagefield to indicate the stop reasonmaxSteps(not on other incomplete executions)Tool logging cleanup:
type: "object"Test Plan
maxStepsvalue (e.g., 2)Agent stopped: reached maximum steps (2)result.messagecontains the max steps indicationresult.successisfalseandresult.completedisfalseresult.actionsstill contains all actions performed before stopping