Skip to content

Conversation

fazlerahmanejazi
Copy link
Contributor

@fazlerahmanejazi fazlerahmanejazi commented Oct 1, 2025

Motivation and Context

KG-437

  • Swaps the "provider:model" string for a typed ModelInfo data class across agent events.
  • Added ModelInfo in agents-utils (no circular deps)
  • LLModel.toModelInfo() lives in prompt-llm
  • Kept eventString for backward compatibility
  • Wired into serialization; tests updated and green

Breaking Changes

  • No breaking changes for consumers using the old string—it's still parsed. New code should prefer ModelInfo.

Type of the changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tests improvement
  • Refactoring

Checklist

  • The pull request has a description of the proposed change
  • I read the Contributing Guidelines before opening the pull request
  • The pull request uses develop as the base branch
  • Tests for the changes have been added
  • All new and existing tests passed
Additional steps for pull requests adding a new feature
  • An issue describing the proposed change exists
  • The pull request includes a link to the issue
  • The change was discussed and approved in the issue
  • Docs have been added / updated

Copy link
Collaborator

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

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

Thank you, @fazlerahmanejazi
I have Couple of notes, but in general looks good to me

* Backwards compatibility: provides the same string format as current eventString
* Format: "provider:model"
*/
public val eventString: String get() = "$provider:$model"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since it's use-case specific, wouldn't it be better to move it to an extension function in the events module? Or let's not mention "events" use case here (rename)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be deprecated, keeping it for backwards compatibility(improved docs and added deprecation warnings).


@Test
fun `test fromString with invalid format`() {
val modelInfo = ModelInfo.fromString("invalid-format")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we create such malformed ModelInfos, or isn't it better to throw a ParseException. We may define a static constant ModelInfo.UNDEFINED for undefined usecases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Added ModelInfo.UNDEFINED

@kpavlov kpavlov requested review from kpavlov and sdubov October 1, 2025 08:46
@kpavlov kpavlov added the enhancement New feature or request label Oct 1, 2025
@kpavlov
Copy link
Collaborator

kpavlov commented Oct 1, 2025

The ModelInfo might be reused for #633

Copy link
Contributor

@sdubov sdubov left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. I have several comments about naming and deprecation. It would be nice to fix them. Other than that LGTM!

* Backwards compatibility: provides the same string format as current eventString
* Format: "provider:model"
*/
public val eventString: String get() = "$provider:$model"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's deprecate this as well. I think we need to drop it in the next release in favour of a new format string: provider/model_id below.

* Human-readable display name for the model
* Falls back to "provider/model" if displayName is not provided
*/
public val humanReadableName: String get() = displayName ?: "$provider/$model"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe name it modelIdentifierName or modelIdentifierString?

* @deprecated Use model.eventString instead
*/
@Deprecated("Use model.eventString instead", ReplaceWith("model.eventString"))
public val modelString: String get() = model.eventString
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also add a deprecated constructor to keep backward compatibility:

/**
     * @deprecated Use constructor with model parameter of type [ModelInfo]: 
     *             LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)
     */
    @Deprecated(
        message = "Please use constructor with model parameter of type [ModelInfo]: LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)",
        replaceWith = ReplaceWith("LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)")
    )
    public constructor(
        runId: String,
        prompt: Prompt,
        model: String,
        tools: List<String>,
        eventId: String = LLMCallStartingEvent::class.simpleName!!,
        timestamp: Long = Clock.System.now().toEpochMilliseconds()
    ) : this(runId, prompt, ModelInfo.fromString(model), tools, eventId, timestamp)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, done!

Copy link
Contributor

@sdubov sdubov left a comment

Choose a reason for hiding this comment

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

Thank you for fixes. Approve!

Copy link
Collaborator

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

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

Thank you, @fazlerahmanejazi

@fazlerahmanejazi
Copy link
Contributor Author

@sdubov @kpavlov Could you also approve the workflows for this PR so checks can run? Thanks!

*/
@Deprecated(
message = "Please use constructor with model parameter of type [ModelInfo]: LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)",
replaceWith = ReplaceWith("LLMCallStartingEvent(runId, prompt, model, tools, eventId, timestamp)")
Copy link
Collaborator

Choose a reason for hiding this comment

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

eventId was removed from method signature. ReplaceWith and docs need an update

Copy link
Contributor Author

@fazlerahmanejazi fazlerahmanejazi Oct 2, 2025

Choose a reason for hiding this comment

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

done, both #905 and #893 would need a workflow run!

@fazlerahmanejazi fazlerahmanejazi force-pushed the kg-437-agent-events-modelinfo branch from 031e1ee to f619567 Compare October 3, 2025 16:15
@fazlerahmanejazi fazlerahmanejazi force-pushed the kg-437-agent-events-modelinfo branch from 88621f4 to 0511f31 Compare October 3, 2025 23:15
@fazlerahmanejazi fazlerahmanejazi force-pushed the kg-437-agent-events-modelinfo branch from b31feb5 to 6b845fc Compare October 4, 2025 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants