Skip to content

feat: agent reply wrapper in component client - #1318

Merged
aludwiko merged 11 commits into
mainfrom
actor-reply-wrapper-client-version
Feb 23, 2026
Merged

aludwiko merged 11 commits into
mainfrom
actor-reply-wrapper-client-version

Conversation

@aludwiko

Copy link
Copy Markdown
Contributor

No description provided.

@aludwiko
aludwiko marked this pull request as draft February 11, 2026 11:10

@octonato octonato 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.

This proposal looks more complex than #1317, but it will allow us to have an API as I suggested in #1317.

AgentReply<SomeResponse> reply = componentClient
    .forAgent()
    .inSession(newSessionId())
    .method(SomeAgent::mapLlmResponse)
    .withDetailedReply()
    .invoke("hello");

@aludwiko
aludwiko marked this pull request as ready for review February 13, 2026 13:15
@aludwiko

Copy link
Copy Markdown
Contributor Author

Ok, this one is ready for review.

@patriknw patriknw 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.

looking good, but missing docs


private def toTokenUsage(metadata: Metadata): Agent.TokenUsage = {
val input = metadata.get("input_tokens").map[Integer](_.toInt).orElse(0)
val output = metadata.get("output_tokens").map[Integer](_.toInt).orElse(0)

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.

shall we define those metadata keys in the spi to make sure runtime and sdk use the same constants

@aludwiko aludwiko Feb 13, 2026 •

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.

yeap we could, should we also add some prefix, spi-input-tokens, spi-agent-input-tokens, agent-input-tokens?

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.

yes, probably good to avoid possible name clash with user metadata

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.

ok, changed

@aludwiko

Copy link
Copy Markdown
Contributor Author

docs added, and here is matching PR in the runtime: https://github.com/lightbend/akka-runtime/pull/4762/changes

@octonato octonato 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.

Looks good, but we still have a type issue to solve.

See my comment below.

Comment on lines +27 to +33
override def withMetadata(metadata: Metadata): ComponentMethodRefImpl[A1, R] =
componentMethodRefImpl.withMetadata(metadata)

override def withRetry(retrySettings: RetrySettings): ComponentMethodRefImpl[A1, R] =
componentMethodRefImpl.withRetry(retrySettings)

override def withRetry(maxRetries: Int): ComponentMethodRefImpl[A1, R] = componentMethodRefImpl.withRetry(maxRetries)

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.

We will need some more type massage here.

It won't be possible to call any of those methods and then withDetailedReply

componentClient
    .forAgent()
    .inSession(newSessionId())
    .method(SomeAgent::mapLlmResponse)
    .withRetry(2) // returns ComponentMethodRefImpl
    .withDetailedReply() // non-existent method
    .invoke("hello");

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.

right, that complicates things, but I think now I support it

@patriknw patriknw 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.

LGTM

@octonato octonato 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.

LGTM

@aludwiko
aludwiko merged commit e37ee9f into main Feb 23, 2026
38 of 39 checks passed
@aludwiko
aludwiko deleted the actor-reply-wrapper-client-version branch February 23, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants