Skip to content

dev -> main (Mar 29) #1294

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

Merged
merged 175 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
e8b624c
feat(responses-api): Initialize Responses API
HamadaSalhab Mar 13, 2025
fdf08aa
Remove `response-api` service and move relevant typespec code
HamadaSalhab Mar 13, 2025
88050a8
feat(agents-api): Add responses endpoint
HamadaSalhab Mar 13, 2025
cb98b56
chore(scripts): Remove generate_.openapi_responses_code.sh
HamadaSalhab Mar 13, 2025
3947ac3
chore(agents-api): generate typespec code
Ahmad-mtos Mar 13, 2025
98a8039
chore(agents-api): Add placeholder /responses endpoint (wip)
HamadaSalhab Mar 13, 2025
7da0d97
refactor: Lint agents-api (CI)
HamadaSalhab Mar 13, 2025
dac0c30
fix(agents-api): fix response endpoint path
Ahmad-mtos Mar 13, 2025
0f1124d
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 13, 2025
b1bb1bf
feat(agents-api): add initial model converters
Ahmad-mtos Mar 13, 2025
4dae32d
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 13, 2025
3915db4
feat(agents-api): add create_response logic
Ahmad-mtos Mar 13, 2025
8d5a860
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 13, 2025
43fa6a2
fix(agents-api): Bug fixes in responses endpoint
HamadaSalhab Mar 13, 2025
563bc94
chore(agents-api): Remove debugging prints
HamadaSalhab Mar 13, 2025
0d36869
fix(agents-api): Lint
HamadaSalhab Mar 13, 2025
4e53845
chore(agents-api): Minor refactor
HamadaSalhab Mar 13, 2025
adb36b3
chore(agents-api): Inject background tasks automatically in responses…
HamadaSalhab Mar 13, 2025
5ec2451
refactor: Lint agents-api (CI)
HamadaSalhab Mar 13, 2025
beefff2
fix(agents-api): Minor fix
HamadaSalhab Mar 13, 2025
a3a2dc9
Merge pull request #1241 from julep-ai/f/responses-api-logic
HamadaSalhab Mar 13, 2025
44ea420
chore(agents-api): generate typespec code
Ahmad-mtos Mar 14, 2025
7c4ab01
feat(agents-api): fork old sessions if provided id
Ahmad-mtos Mar 14, 2025
57aaa2c
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 14, 2025
ee00f04
fix(agents-api): fix previous_response_id in response
Ahmad-mtos Mar 14, 2025
664ccbb
feat(agents-api): add get response endpoint
Ahmad-mtos Mar 14, 2025
467d839
fix(agents-api): expose the get endpoint correctly
Ahmad-mtos Mar 14, 2025
620e9c8
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 14, 2025
8ef89d0
feat(agents-api): Add ResponseItemList and other models to Response's…
HamadaSalhab Mar 14, 2025
5d2ddf9
Minor fix
HamadaSalhab Mar 14, 2025
f2dd15c
fix(agents-api): Add missing FunctionToolCallOutput model to Response…
HamadaSalhab Mar 14, 2025
4aef385
chore(agents-api): Add missing tsp models in Responses API
HamadaSalhab Mar 14, 2025
924408f
chore(agents-api): Implement get_response logic in Responses endpoint…
HamadaSalhab Mar 14, 2025
e3f6637
refactor: Lint agents-api (CI)
HamadaSalhab Mar 14, 2025
e624708
fix(agents-api): Minor fixes for GET /responses
HamadaSalhab Mar 17, 2025
f783b70
fix(agents-api | typespec): Fix typo
HamadaSalhab Mar 17, 2025
f315ef8
fix(agents-api): Fix type checks and lint
HamadaSalhab Mar 17, 2025
69dc2ff
Merge pull request #1245 from julep-ai/f/responses-sessions
HamadaSalhab Mar 17, 2025
60671ce
feat(agents-api): Add vision support for /responses endpoint
HamadaSalhab Mar 17, 2025
36f195d
fix(agents-api): Minor fixes
HamadaSalhab Mar 18, 2025
8c8f7d4
chore(agents-api): Minor refactor
HamadaSalhab Mar 18, 2025
944c6b5
Merge branch 'f/responses-api' into f/responses-api-typespec
HamadaSalhab Mar 18, 2025
97b257d
chore(agents-api): generate typespec
Ahmad-mtos Mar 18, 2025
0500d8f
feat(agents-api): Add static task validations to catch errors beforehand
creatorrr Mar 18, 2025
20e62c6
fix: change response type returned
Ahmad-mtos Mar 18, 2025
dfc6423
fix(agents-api): Misc fixes to /responses endpoint
HamadaSalhab Mar 18, 2025
172d896
Merge pull request #1247 from julep-ai/f/responses-api-typespec
HamadaSalhab Mar 18, 2025
628c9d9
feat(agents-api): add web search tool call
Vedantsahai18 Mar 19, 2025
fd89df8
chore(agents-api): remove print statement
Vedantsahai18 Mar 19, 2025
f33947e
Update agents-api/agents_api/routers/responses/create_response.py
Vedantsahai18 Mar 19, 2025
cc4c950
chore(agents-api): misc refactors
Vedantsahai18 Mar 19, 2025
00cf088
Update agents-api/agents_api/activities/tool_executor.py
Vedantsahai18 Mar 19, 2025
07a53cc
chore: remove tools argument from process_tool_calls func
Vedantsahai18 Mar 19, 2025
32a417b
refactor: Lint agents-api (CI)
Vedantsahai18 Mar 19, 2025
cbc383a
chore(agents-api): added logging to tool_executor
Vedantsahai18 Mar 19, 2025
0d5bccc
chore(agents-api): moved tool_executor model to autogen
Vedantsahai18 Mar 19, 2025
92a9726
feat(agents-api): add a flag for enabling responses API
Ahmad-mtos Mar 19, 2025
12c29fe
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 19, 2025
c2a4b57
chore(responses-api): Add tool calls to output in responses api
HamadaSalhab Mar 19, 2025
f38c668
Merge pull request #1268 from julep-ai/f/web-search-tool-call
HamadaSalhab Mar 19, 2025
7690c37
Merge branch 'f/responses-api' into f/responses-docker
Ahmad-mtos Mar 19, 2025
4957c16
feat(deploy): add responses docker compose
Ahmad-mtos Mar 19, 2025
c37cdd6
feat(deploy): add env example
Ahmad-mtos Mar 19, 2025
93bf5c5
Update .env.example
creatorrr Mar 19, 2025
c52217f
───────┬──────────────────────────────────────────────────…
creatorrr Mar 19, 2025
5906da7
───────┬──────────────────────────────────────────────────…
creatorrr Mar 19, 2025
522ac81
refactor: Lint agents-api (CI)
creatorrr Mar 19, 2025
9dc1cc0
chore(agents-api): Reasoning support & misc fixes in Responses
HamadaSalhab Mar 19, 2025
4278564
Merge branch 'dev' into f/responses-api
HamadaSalhab Mar 19, 2025
348cdc2
docs: initital docs added for response api
Vedantsahai18 Mar 20, 2025
142d0b8
Update documentation/responses/quickstart.mdx
Vedantsahai18 Mar 20, 2025
b1831dc
docs: minor fixes
Vedantsahai18 Mar 20, 2025
2e91807
chore(agents-api): change route args to get developer data directly i…
Vedantsahai18 Mar 20, 2025
9d96559
fix(agents-api): remove get_developer_data call from create_response
Ahmad-mtos Mar 20, 2025
49da987
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 20, 2025
62c03fe
Merge branch 'f/responses-api' into c/reponses-reasoning
HamadaSalhab Mar 20, 2025
125194f
Merge pull request #1277 from julep-ai/c/reponses-reasoning
HamadaSalhab Mar 20, 2025
089a327
Merge branch 'dev' into f/static-task-validation
creatorrr Mar 20, 2025
0a98da1
Update agents-api/agents_api/activities/execute_api_call.py
creatorrr Mar 20, 2025
2fa02a7
Update agents-api/agents_api/activities/task_steps/base_evaluate.py
creatorrr Mar 20, 2025
8364eda
feat(deploy): add a standalone docker compose
Ahmad-mtos Mar 20, 2025
7bc6712
Merge branch 'f/responses-api' into f/response-api-docs-tests
creatorrr Mar 20, 2025
c9bfcba
Merge branch 'f/responses-api' into f/responses-docker
Ahmad-mtos Mar 20, 2025
17814ad
Merge pull request #1272 from julep-ai/f/responses-docker
Ahmad-mtos Mar 20, 2025
34688b8
chore(agents-api): fix indentation and merge conflicts
Vedantsahai18 Mar 20, 2025
1fa0121
Update documentation/responses/quickstart.mdx
Vedantsahai18 Mar 20, 2025
0026688
chore(Agents-api): minor fix
Vedantsahai18 Mar 20, 2025
a11d191
refactor(agents-api): Moved some stuff around
creatorrr Mar 20, 2025
fc02428
Merge branch 'f/responses-api' into f/response-api-docs-tests
Vedantsahai18 Mar 21, 2025
1e6c53b
fix(agents-api): Misc fixes to Responses API
HamadaSalhab Mar 21, 2025
16235c7
docs: init quickstart page and added example for concepts
Vedantsahai18 Mar 21, 2025
8ec9831
docs: updated the quickstart for standalone docker setup
Vedantsahai18 Mar 21, 2025
6479abb
docs: minor fix
Vedantsahai18 Mar 21, 2025
acce5df
docs: cmd fix
Vedantsahai18 Mar 21, 2025
00d1a2d
Merge branch 'f/responses-api' into f/response-api-docs-tests
Vedantsahai18 Mar 21, 2025
d92a2ba
fix: minimize .env.example + misc fixes
Ahmad-mtos Mar 21, 2025
50d84ad
refactor: Lint agents-api (CI)
Ahmad-mtos Mar 21, 2025
c7d1002
fix: remove comment
Ahmad-mtos Mar 21, 2025
c67528e
docs: added tutorial page for response api
Vedantsahai18 Mar 21, 2025
04919d3
Update documentation/responses/tutorials.mdx
creatorrr Mar 22, 2025
a48b922
Update documentation/responses/tutorials.mdx
creatorrr Mar 22, 2025
160bc3b
Update concepts.mdx
creatorrr Mar 22, 2025
c2341be
Update tutorials.mdx
creatorrr Mar 22, 2025
98aa9c8
Update standalone-docker-compose.yaml
creatorrr Mar 22, 2025
85870ef
Update .env.example
creatorrr Mar 22, 2025
be7df29
Update and rename responses-docker-compose.yaml to responses-build-do…
creatorrr Mar 22, 2025
3f5b146
Update standalone-docker-compose.yaml
creatorrr Mar 22, 2025
aa39a43
Update Dockerfile.migrations
creatorrr Mar 22, 2025
10304dd
Merge pull request #1281 from julep-ai/x/responses-docker
creatorrr Mar 22, 2025
07c462b
Merge pull request #1278 from julep-ai/f/response-api-docs-tests
creatorrr Mar 22, 2025
3e9781d
chore(agents-api): added postgres pwd in docker for memory-store
Vedantsahai18 Mar 24, 2025
501edcf
chore(agnets-api): docker refactor
Vedantsahai18 Mar 24, 2025
f804b07
docs: misc updates
Vedantsahai18 Mar 24, 2025
0346b1e
Update agents-api/agents_api/routers/responses/create_response.py
HamadaSalhab Mar 24, 2025
99b3c5b
Minor doc fix
HamadaSalhab Mar 24, 2025
db543de
refactor: Lint agents-api (CI)
HamadaSalhab Mar 24, 2025
17e33a4
feat(responses-api): Add missing AGENTS_API_KEY_HEADER_NAME env var
HamadaSalhab Mar 24, 2025
ff41291
Merge branch 'f/responses-api' of https://github.com/julep-ai/julep i…
HamadaSalhab Mar 24, 2025
c1cfe01
Fix typo
HamadaSalhab Mar 24, 2025
8d89847
fix(agents-api): Do not prefix `openai/` for non-hosted litellm service
HamadaSalhab Mar 24, 2025
8206602
docs: added roadmap page and model info
Vedantsahai18 Mar 24, 2025
9bc4b62
docs: wget cmd updated
Vedantsahai18 Mar 25, 2025
41a0f8f
fix(responses-api): Fix typo
HamadaSalhab Mar 25, 2025
f3a7add
Merge branch 'f/responses-api' of https://github.com/julep-ai/julep i…
HamadaSalhab Mar 25, 2025
ace8ee9
Update agents-api/agents_api/common/utils/task_validation.py
creatorrr Mar 25, 2025
60cc27c
docs: updated the responses page to reflect HN changes
Vedantsahai18 Mar 25, 2025
ba55e80
chore(integrations): handle None case for Algolia attributes_to_retri…
Vedantsahai18 Mar 26, 2025
b32f103
docs: julep page updated
Vedantsahai18 Mar 26, 2025
bcceead
fix(responses-api): Fix typos
HamadaSalhab Mar 26, 2025
4024dbd
fix(responses-api): Fix typo
HamadaSalhab Mar 26, 2025
c94f5be
───────┬──────────────────────────────────────────────────…
creatorrr Mar 26, 2025
f4d252f
feat: Regenerate .json for schema
creatorrr Mar 26, 2025
d9f355a
Merge branch 'f/responses-api' of https://github.com/julep-ai/julep i…
HamadaSalhab Mar 26, 2025
19cbf0e
chore(responses-api): Change agents api port in scalar
HamadaSalhab Mar 26, 2025
eea85d2
chore(agents-api): expose only responses endpoints
Ahmad-mtos Mar 26, 2025
cbff7f4
fix(integrations-service): Add missing to docker compose
HamadaSalhab Mar 26, 2025
f260074
fix(responses-api): Fix migrations image tag
HamadaSalhab Mar 26, 2025
7095c7e
feat(docs): Add Responses API examples
HamadaSalhab Mar 26, 2025
bbfa7bf
feat(documentation): Add agents sdk examples in open responses
HamadaSalhab Mar 26, 2025
7a41197
fix(documentation): Fix typo
HamadaSalhab Mar 26, 2025
bd07e8f
Merge pull request #1274 from julep-ai/fix-sql-injection-issue-1266
creatorrr Mar 26, 2025
0a28684
doc: Responses API / CLI
creatorrr Mar 26, 2025
2fb03fc
readme updates
Vedantsahai18 Mar 26, 2025
e7d01f1
Merge pull request #1239 from julep-ai/f/responses-api
creatorrr Mar 26, 2025
11d61e8
chore(docs): update TOC
creatorrr Mar 26, 2025
7e6d1c5
docs: removed tutorials page + updates the cli cmds
Vedantsahai18 Mar 26, 2025
85f71d8
Merge pull request #1290 from julep-ai/d/responses
Vedantsahai18 Mar 26, 2025
4929cc8
docs: upgraded mintlify to docs.json + fixed broken links + changed d…
Vedantsahai18 Mar 28, 2025
fbe4da3
fix(agents-api): add developer id to litellm requests
Ahmad-mtos Mar 28, 2025
7e0446c
feat(agents-api): Made trigram/fuzzy text search parameters configura…
Vedantsahai18 Mar 28, 2025
6cb5b18
chore(agents-api): ellipsis recommended fixes
Vedantsahai18 Mar 28, 2025
fa39a01
address comments left by @creatorrr on #1292 (fix(agents-api): add de…
ellipsis-dev[bot] Mar 29, 2025
06001ee
refactor: Lint agents-api (CI)
ellipsis-dev[bot] Mar 29, 2025
55120ee
fix(agents-api): Fixes for PR comments
creatorrr Mar 29, 2025
3ebd476
Update agents-api/tests/test_task_validation.py
creatorrr Mar 29, 2025
af0a860
hotfix(agents-api): Fix subquery cardinality issue
creatorrr Mar 30, 2025
8194822
chore(docker): update litellm-database image to version v1.65.0-stable
Vedantsahai18 Mar 31, 2025
9bd062b
chore(agents-api): update alpha parameter value from 0.7 to 0.5 acros…
Vedantsahai18 Mar 31, 2025
0fbcf13
Merge pull request #1295 from julep-ai/ellipsis/jrun_vay18cAPjPLJWqMq…
Ahmad-mtos Mar 31, 2025
fb1ca2c
Merge pull request #1292 from julep-ai/x/usage-tracking
Ahmad-mtos Mar 31, 2025
b226360
Merge pull request #1263 from julep-ai/f/static-task-validation
Ahmad-mtos Mar 31, 2025
ad893c0
Merge pull request #1298 from julep-ai/x/fix-subquery
creatorrr Mar 31, 2025
68e86aa
docs: add notes on default parameters for full-text, embedding, and h…
Vedantsahai18 Mar 31, 2025
5640044
Merge pull request #1299 from julep-ai/x/litellm
creatorrr Mar 31, 2025
5d1b859
Merge pull request #1293 from julep-ai/x/trigram-param-configurable
creatorrr Mar 31, 2025
6190067
docs: remove deprecated openapi.yaml symlink
Vedantsahai18 Apr 1, 2025
4cfb7d4
Merge branch 'dev' into d/mintlify-version-upgrade
Vedantsahai18 Apr 1, 2025
ca551e7
Merge pull request #1291 from julep-ai/d/mintlify-version-upgrade
creatorrr Apr 1, 2025
473064f
fix(agents-api): disable task validation
Ahmad-mtos Apr 1, 2025
7a91610
Merge pull request #1301 from julep-ai/x/task-validation-patch
Ahmad-mtos Apr 1, 2025
8a7c101
fix(agents-api): improve expression validation for comprehensions and…
Ahmad-mtos Apr 1, 2025
afbff80
refactor: Lint agents-api (CI)
Ahmad-mtos Apr 1, 2025
de49fca
chore(agents-api): add tests
Ahmad-mtos Apr 1, 2025
5d3d735
refactor: Lint agents-api (CI)
Ahmad-mtos Apr 1, 2025
5bdb132
Merge pull request #1302 from julep-ai/x/task-validation-variables
Ahmad-mtos Apr 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,10 @@ INTEGRATIONS_SENTRY_DSN=<sentry_dsn>
# API Keys needed for the `humanize_text` method in `evaluate` step
SAPLING_API_KEY=<your_sapling_api_key>
COPYLEAKS_API_KEY=<your_copyleaks_api_key>


# Responses Flag
# ---------------

# Set to true to enable responses in the API
ENABLE_RESPONSES=false
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@
<h3><i>Serverless AI Workflows for Data & ML Teams</i></h3>
</div>

## 🎉 Announcing: Julep Open Responses API (Alpha)

<div style="padding: 15px; border-left: 4px solid #4CAF50; margin: 20px 0;">

We're excited to announce the launch of our Open Responses API! This new API offers:

1. **OpenAI-compatible interface** - A drop-in replacement for your existing code
2. **Self-hosted, open-source implementation** - Works with any LLM backend
3. **Model Provider Agnostic** - Connect to any LLM provider (OpenAI, Anthropic, etc.)

The Open Responses API makes it easy to integrate with your existing applications while adding powerful new capabilities.

Ready to try it out? Check out our [Open Responses API documentation](https://docs.julep.ai/responses/quickstart) to get started!
</div>

Julep is a serverless platform that helps data and ML teams build sophisticated AI workflows. It provides a robust foundation for orchestrating complex AI operations, managing state across interactions, and integrating with your existing data infrastructure and tools.

Whether you're building data pipelines or creating AI workflows, Julep makes it easy to compose and scale LLM-powered workflows without managing infrastructure. Imagine you want to build an AI agent that can do more than just answer simple questions—it needs to handle complex tasks, remember past interactions, and maybe even use other tools or APIs. That's where Julep comes in. Our platform handles the heavy lifting so you can focus on building intelligent solutions for your business.
Expand Down
83 changes: 63 additions & 20 deletions agents-api/agents_api/activities/execute_api_call.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import base64
import json
from typing import Any, TypedDict

import httpx
from beartype import beartype
from httpx import Response
from temporalio import activity

from ..autogen.openapi_model import ApiCallDef
Expand All @@ -30,41 +28,86 @@ async def execute_api_call(
request_args: RequestArgs,
) -> Any:
try:
# Use client with timeout and proper error handling
async with httpx.AsyncClient(timeout=600) as client:
arg_headers: dict = request_args.pop("headers", None) or {}
# Extract URL, method, and headers from arguments
arg_url = request_args.pop("url", None)
arg_headers = request_args.pop("headers", None)
arg_method = request_args.pop("method", None)

# Allow the method to be overridden by the request_args
response: Response = await client.request(
method=request_args.pop("method", api_call.method),
url=str(request_args.pop("url", api_call.url)),
headers={**arg_headers, **(api_call.headers or {})},
follow_redirects=request_args.pop(
"follow_redirects", api_call.follow_redirects
),
method = arg_method or api_call.method
url = arg_url or str(api_call.url)

# Merge headers from both arguments and API call definition
merged_headers = (arg_headers or {}) | (api_call.headers or {})

# Allow follow_redirects to be overridden by request_args
follow_redirects = request_args.pop("follow_redirects", api_call.follow_redirects)

# Log the request (debug level)
if activity.in_activity():
activity.logger.debug(f"Making API call: {method} to {url}")

# Execute the HTTP request
response = await client.request(
method=method,
url=url,
headers=merged_headers,
follow_redirects=follow_redirects,
**request_args,
)
# Raise an error if the response is not successful
response.raise_for_status()
# Get the content of the response

# Raise for HTTP errors
try:
response.raise_for_status()
except httpx.HTTPStatusError as e:
# For HTTP errors, include response body in the error for debugging
error_body = e.response.text[:500] if e.response.text else "(empty body)"
if activity.in_activity():
activity.logger.error(
f"HTTP error {e.response.status_code} in API call: {e!s}\n"
f"Response body: {error_body}"
)
raise

# Encode content as base64 for safety
content_base64 = base64.b64encode(response.content).decode("ascii")
# Create a response dict with the status code, headers, and content

# Prepare response dictionary
response_dict = {
"status_code": response.status_code,
"headers": dict(response.headers),
"content": content_base64,
}
# Try to parse the response as JSON

# Try to parse JSON response if possible
try:
response_dict["json"] = response.json()
except json.JSONDecodeError as e:
except Exception as e:
response_dict["json"] = None
activity.logger.debug(f"Failed to parse JSON response: {e}")
content_preview = response.text[:100] if response.text else "(empty)"
if activity.in_activity():
activity.logger.debug(
f"Response not valid JSON: {e!s}\n"
f"Content-Type: {response.headers.get('content-type')}\n"
f"Content preview: {content_preview}"
)

return response_dict

except BaseException as e:
except httpx.TimeoutException as e:
if activity.in_activity():
activity.logger.error(f"Error in execute_api_call: {e}")

activity.logger.error(f"Timeout in API call: {e!s}")
raise
except httpx.RequestError as e:
# Network-level errors
if activity.in_activity():
activity.logger.error(f"Request error in API call: {e!s}")
raise
except Exception as e:
if activity.in_activity():
activity.logger.error(f"Error in execute_api_call: {e!s}")
raise


Expand Down
44 changes: 18 additions & 26 deletions agents-api/agents_api/activities/task_steps/base_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,24 @@

from ...common.exceptions.executions import EvaluateError
from ...common.protocol.tasks import StepContext
from ...common.utils.task_validation import backwards_compatibility
from ..utils import get_evaluator


def backwards_compatibility(expr: str) -> str:
expr = expr.strip()

if expr.startswith("$ "):
return expr

if "{{" in expr:
return "$ f'''" + expr.replace("{{", "{").replace("}}", "}") + "'''"

if (
(expr.startswith("[") and expr.endswith("]"))
or (expr.startswith("_[") and expr.endswith("]"))
or (expr.startswith("_.") and expr.endswith("]"))
or "outputs[" in expr
or "inputs[" in expr
or expr == "_"
):
return "$ " + expr

return expr


# Recursive evaluation helper function
def _recursive_evaluate(expr, evaluator: SimpleEval):
# Handle PyExpression type from the model
if hasattr(expr, "root") and isinstance(expr.root, str):
# Extract the string from the RootModel
expr = expr.root

if isinstance(expr, str):
try:
expr = backwards_compatibility(expr)
expr = expr.strip()
if isinstance(expr, str) and expr.startswith("$ "):
expr = expr[2:].strip()
# Remove $ and any space after it
expr = expr[1:].strip()
else:
expr = f"f'''{expr}'''"
return evaluator.eval(expr)
Expand Down Expand Up @@ -79,10 +65,16 @@ async def base_evaluate(

values = values or {}
if context:
values.update(await context.prepare_for_step())
# NOTE: We limit the number of inputs to 50 to avoid excessive memory usage
values.update(await context.prepare_for_step(limit=50))

# Handle PyExpression objects and strings similarly
if isinstance(exprs, str) or (hasattr(exprs, "root") and isinstance(exprs.root, str)):
input_len = 1
else:
input_len = len(exprs)

input_len = 1 if isinstance(exprs, str) else len(exprs)
assert input_len > 0, "exprs must be a non-empty string, list or dict"
assert input_len > 0, "exprs must be a non-empty string, PyExpression, list or dict"

extra_lambdas = {}
if extra_lambda_strs:
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/activities/task_steps/prompt_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ async def prompt_step(context: StepContext) -> StepOutcome:
exclude_unset=True,
)
passed_settings.update(passed_settings.pop("settings", {}) or {})
passed_settings["user"] = str(context.execution_input.developer_id)

if not passed_settings.get("tools"):
passed_settings.pop("tool_choice", None)
Expand Down
Loading