Skip to content

token usage for act - #636

Merged
seanmcguire12 merged 2 commits into
mainfrom
token-usage-act
Apr 5, 2025
Merged

seanmcguire12 merged 2 commits into
mainfrom
token-usage-act

Conversation

@seanmcguire12

Copy link
Copy Markdown
Member

why

  • add token usage for act

what changed

  • pass fromAct parameter from within act handler -> observe handler -> observe inference if observe is being called inside act

test plan

  • evals

@changeset-bot

changeset-bot Bot commented Apr 5, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e3e24de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@browserbasehq/stagehand Patch

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

@greptile-apps greptile-apps Bot left a comment

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.

PR Summary

This PR introduces a new fromAct parameter to track token usage when observations are triggered from an act. The parameter is properly propagated through observeHandler, inference, and actHandler for correct metrics logging.

  • In /lib/handlers/observeHandler.ts, the observe method now accepts fromAct and updates metrics using StagehandFunctionName.ACT when applicable.
  • In /lib/inference.ts, fromAct adjusts log file prefixes and summary keys for accurate token tracking.
  • In /lib/handlers/actHandler.ts, observe calls set fromAct to true, ensuring consistent behavior.
  • End-to-end eval tests are recommended to verify these updates.

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@kamath kamath left a comment

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.

i see the drawbacks here, but ig we can deal with that once it starts to become a pain

@seanmcguire12 seanmcguire12 added the act These changes pertain to the act function label Apr 5, 2025
@seanmcguire12
seanmcguire12 merged commit 9037430 into main Apr 5, 2025
@github-actions github-actions Bot mentioned this pull request Apr 5, 2025
felipeofdev-ai pushed a commit to felipeofdev-ai/stagehand that referenced this pull request Aug 4, 2026
* token usage for act

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

Labels

act These changes pertain to the act function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants