Skip to content

feat(memory-store,agents-api): Add special foreign fields to usage table #1480

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

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

creatorrr
Copy link
Contributor

Signed-off-by: Diwank Singh Tomer diwank.singh@gmail.com

Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
@creatorrr creatorrr requested a review from Ahmad-mtos June 9, 2025 13:58
Copy link
Contributor

qodo-merge-for-open-source bot commented Jun 9, 2025

CI Feedback 🧐

(Feedback updated until commit 832f644)

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: Typecheck

Failed stage: Typecheck [❌]

Failure summary:

The action failed due to a pytype static type checking error in the file
agents_api/activities/task_steps/prompt_step.py at line 110, column 43. The error indicates that the
code is trying to access the execution_id attribute on a None value. Specifically,
context.execution_input.execution is None (of type
Optional[agents_api.autogen.Executions.Execution]), but the code attempts to access .execution_id on
it without checking if it's not None first.

Relevant error logs:
1:  ##[group]Operating System
2:  Ubuntu
...

997:  prune-cache: true
998:  ignore-nothing-to-cache: false
999:  ##[endgroup]
1000:  Downloading uv from "https://github.com/astral-sh/uv/releases/download/0.7.12/uv-x86_64-unknown-linux-gnu.tar.gz" ...
1001:  [command]/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/c4f33034-7165-45f3-a7a3-b61a36928cd3 -f /home/runner/work/_temp/32ecd4c3-ccfc-423b-8f85-e0719c81bc9f
1002:  Added /opt/hostedtoolcache/uv/0.7.12/x86_64 to the path
1003:  Added /home/runner/.local/bin to the path
1004:  Set UV_CACHE_DIR to /home/runner/work/_temp/setup-uv-cache
1005:  Successfully installed uv version 0.7.12
1006:  Searching files using cache dependency glob: **/uv.lock
1007:  /home/runner/work/julep/julep/agents-api/uv.lock
1008:  /home/runner/work/julep/julep/cli/uv.lock
1009:  /home/runner/work/julep/julep/integrations-service/uv.lock
1010:  Found 3 files to hash.
1011:  Trying to restore uv cache from GitHub Actions cache with key: setup-uv-1-x86_64-unknown-linux-gnu-0.7.12-d2fb266502043ea806ace17d24fc614bc58c57b06c32d25d4a98237661d5d333
1012:  ##[warning]Failed to restore: getCacheEntry failed: Cache service responded with 503
1013:  No GitHub Actions cache found for key: setup-uv-1-x86_64-unknown-linux-gnu-0.7.12-d2fb266502043ea806ace17d24fc614bc58c57b06c32d25d4a98237661d5d333
...

1857:  [193/369] check agents_api.routers.sessions.chat
1858:  [194/369] check agents_api.routers.tasks.list_task_executions
1859:  [195/369] check agents_api.routers.tasks.list_execution_transitions
1860:  [196/369] check agents_api.routers.tasks.get_task_details
1861:  [197/369] check agents_api.routers.sessions.render
1862:  [198/369] check agents_api.routers.tasks.get_execution_details
1863:  [199/369] check agents_api.routers.sessions.update_session
1864:  [200/369] check agents_api.routers.sessions.patch_session
1865:  [201/369] check agents_api.common.protocol.tasks
1866:  [202/369] check agents_api.routers.tasks.create_task
1867:  [203/369] check agents_api.routers.tasks.create_or_update_task
1868:  [204/369] check agents_api.routers.sessions.list_sessions
1869:  [205/369] check agents_api.activities.task_steps.base_evaluate
1870:  [206/369] check agents_api.activities.task_steps.get_value_step
1871:  [207/369] check agents_api.activities.task_steps.prompt_step
1872:  FAILED: /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/activities/task_steps/prompt_step.pyi 
1873:  /home/runner/work/julep/julep/agents-api/.venv/bin/python -m pytype.main --disable pyi-error --imports_info /home/runner/work/julep/julep/agents-api/.pytype/imports/agents_api.activities.task_steps.prompt_step.imports --module-name agents_api.activities.task_steps.prompt_step --platform linux -V 3.12 -o /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/activities/task_steps/prompt_step.pyi --analyze-annotated --nofail --none-is-not-bool --quick --strict-none-binding /home/runner/work/julep/julep/agents-api/agents_api/activities/task_steps/prompt_step.py
1874:  /home/runner/work/julep/julep/agents-api/agents_api/activities/task_steps/prompt_step.py:110:43: error: in prompt_step: No attribute 'execution_id' on None [attribute-error]
1875:  In Optional[agents_api.autogen.Executions.Execution]
1876:  passed_settings["execution_id"] = str(context.execution_input.execution.execution_id)
1877:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1878:  For more details, see https://google.github.io/pytype/errors.html#attribute-error
1879:  [208/369] check agents_api.common.interceptors
...

1962:  [291/369] check agents_api.common.exceptions.sessions
1963:  [292/369] check agents_api.workflows.__init__
1964:  [293/369] check agents_api.rec_sum.entities
1965:  [294/369] check tests.test_litellm_utils
1966:  [295/369] check agents_api.routers.sessions.exceptions
1967:  [296/369] check tests.test_expression_validation
1968:  [297/369] check agents_api.rec_sum.__init__
1969:  [298/369] check tests.test_activities_utils
1970:  [299/369] check tests.test_query_utils
1971:  [300/369] check tests.test_base_evaluate
1972:  [301/369] check agents_api.dependencies.content_length
1973:  [302/369] check agents_api.worker.__init__
1974:  [303/369] check tests.__init__
1975:  [304/369] check agents_api.common.utils.json
1976:  [305/369] check agents_api.rec_sum.trim
1977:  ninja: build stopped: cannot make progress due to previous errors.
1978:  Generated API key since not set in the environment: 68493171316526364973935967335813
...

2041:  Generated API key since not set in the environment: 93660443258067706944677011850052
2042:  Generated API key since not set in the environment: 83464286796978652815663272347864
2043:  Generated API key since not set in the environment: 25533779536633547329007416406094
2044:  Generated API key since not set in the environment: 27670057219338804563831501470042
2045:  Generated API key since not set in the environment: 68851386550279526590246137747194
2046:  Generated API key since not set in the environment: 76848876908685454132299546668504
2047:  Generated API key since not set in the environment: 17080099248769434865313122905955
2048:  Generated API key since not set in the environment: 65277573202363112674126055654234
2049:  Generated API key since not set in the environment: 07213022758614072344764205819111
2050:  Generated API key since not set in the environment: 08072098290265176755016988935157
2051:  Generated API key since not set in the environment: 61724892597795974713901085395877
2052:  Generated API key since not set in the environment: 67947287637117764370740656265884
2053:  Generated API key since not set in the environment: 54942207704501428446872603428568
2054:  Analyzing 356 sources with 0 local dependencies
2055:  Leaving directory '.pytype'
2056:  ##[error]Process completed with exit code 1.
2057:  Post job cleanup.

params = {
"messages": messages,
"tools": formatted_tools or None,
"user": str(developer.id),
"tags": developer.tags,
"custom_api_key": x_custom_api_key,
"session_id": session_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

entry_id isn't being passed.

Comment on lines +9 to +13
ADD COLUMN session_id UUID NULL,
ADD COLUMN execution_id UUID NULL,
ADD COLUMN transition_id UUID NULL,
ADD COLUMN entry_id UUID NULL,
ADD COLUMN provider TEXT NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

entry_id and transition_id would be enough, though it's not that bad to add them as fields as well.

Comment on lines 139 to +146
custom_api_used: bool = False,
estimated: bool = False,
metadata: dict[str, Any] | None = None,
session_id: UUID | None = None,
execution_id: UUID | None = None,
transition_id: UUID | None = None,
entry_id: UUID | None = None,
provider: str | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

a lot of variables, better to create a model in typespec to clean up the parameters.

Comment on lines +134 to +141
"input_messages": messages,
"output_content": [
choice.message.content
for choice in response.choices
if hasattr(choice, "message")
and choice.message
and hasattr(choice.message, "content")
]
Copy link
Contributor

Choose a reason for hiding this comment

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

adding all messages to the metadata adds a huge unnecessary memory overhead to the usage table.

Comment on lines +15 to +23
def extract_provider_from_model(model: str) -> str | None:
"""
Extract the provider from a model name.

Args:
model (str): The model name (e.g., "gpt-4", "claude-3-sonnet", "openai/gpt-4")

Returns:
str | None: The provider name (e.g., "openai", "anthropic") or None if unknown
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure about the functionality of this function. Litellm in general with a self-hosted proxy acts very weirdly towards providers. A better way I think is to determine the provider by the api key provided in the litellm-config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants