feat: add function IDs to LettaMessage
function calls and response
#1909
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
FunctionResponse
is generated from aFunctionCallMessage
, but the two do not share an.id
, so there's no way to tell whichFunctionCallMessage
was the source for aFunctionResponse
without looking at the message ordering + timestamps (error prone).This PR adds a new field to the
LettaMessage
response typesFunctionCallMessage
andFunctionResponse
that indicates which "tool call object" they are tied to, allowing the API client to tie the two together easily.Example: for the following streamed POST SSE message:
id
field in thefunction_call
chunk andfunction_return
chunk are differentmessage-cdef867b-b8d2-403c-8e4f-ac23cd6681d1
vsmessage-43cbef99-460f-4f94-8f64-6a8d3aca8840
function_call_id
is the samed102a785-ebcf-4948-9edb-d6581
vsd102a785-ebcf-4948-9edb-d6581
Main caveat (due to the design of the underlying OpenAI ChatCompletions message chunk object):
function_call
,function_call_id
is nested (function_call.function_call.function_call_id
)function_return
,function_call_id
is flat (function_return.function_call_id
)Full response:
Note
My comments from an earlier revision of this PR where there was a bug
Example: for the following streamed POST SSE message:
id
field in thefunction_call
chunk andfunction_return
chunk are differentmessage-456b498b-5526-44d8-9c52-cdfc36bca59a
vsmessage-faf49aa4-3554-4053-a29a-2f1a15827843
function_call_id
is the samecall_TfR9CmIakahLAxko8a5w7PJ8
vs784bb05f-bc25-4f27-999b-86dad
Main caveat (due to the design of the underlying OpenAI ChatCompletions message chunk object):
function_call
,function_call_id
is nested (function_call.function_call.function_call_id
)function_return
,function_call_id
is flat (function_return.function_call_id
)Full response log: