flatagents 2.4.4__tar.gz → 2.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flatagents-2.4.4 → flatagents-2.5.0}/.gitignore +1 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/PKG-INFO +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/__init__.py +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatagent.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatagent.slim.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatagents-runtime.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatagents-runtime.schema.json +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatagents-runtime.slim.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatmachine.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatmachine.slim.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/profiles.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/profiles.slim.d.ts +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/flatagent.py +27 -4
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/openai_codex_client.py +24 -4
- {flatagents-2.4.4 → flatagents-2.5.0}/pyproject.toml +1 -1
- {flatagents-2.4.4 → flatagents-2.5.0}/MACHINES.md +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/README.md +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/README.md +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/__init__.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatagent.schema.json +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/flatmachine.schema.json +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/assets/profiles.schema.json +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/baseagent.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/monitoring.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/profiles.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/__init__.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/anthropic.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/cerebras.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/openai.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/openai_codex_auth.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/openai_codex_login.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/providers/openai_codex_types.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/tool_loop.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/tools.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/utils.py +0 -0
- {flatagents-2.4.4 → flatagents-2.5.0}/flatagents/validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flatagents
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: A lightweight framework for building LLM-powered agents.
|
|
5
5
|
Project-URL: Homepage, https://github.com/memgrafter/flatagents
|
|
6
6
|
Project-URL: Repository, https://github.com/memgrafter/flatagents
|
|
@@ -252,7 +252,7 @@ export interface BackendConfig {
|
|
|
252
252
|
dynamodb_table?: string;
|
|
253
253
|
aws_region?: string;
|
|
254
254
|
}
|
|
255
|
-
export const SPEC_VERSION = "2.
|
|
255
|
+
export const SPEC_VERSION = "2.5.0";
|
|
256
256
|
export interface SDKRuntimeWrapper {
|
|
257
257
|
spec: "flatagents-runtime";
|
|
258
258
|
spec_version: typeof SPEC_VERSION;
|
|
@@ -741,6 +741,13 @@ class FlatAgent:
|
|
|
741
741
|
_external_tools = None
|
|
742
742
|
tools_prompt = self._render_tool_prompt(_mcp_tools)
|
|
743
743
|
|
|
744
|
+
# Session identity is transport metadata, not prompt input.
|
|
745
|
+
# Strip it from input_data so continuation calls (messages=..., no fresh
|
|
746
|
+
# user input) are not misclassified as having new user content.
|
|
747
|
+
codex_session_id = None
|
|
748
|
+
if self._backend == "codex" and "session_id" in input_data:
|
|
749
|
+
codex_session_id = input_data.pop("session_id")
|
|
750
|
+
|
|
744
751
|
# Render prompts
|
|
745
752
|
system_prompt = self._render_system_prompt(input_data, tools_prompt=tools_prompt, tools=_mcp_tools)
|
|
746
753
|
user_prompt = self._render_user_prompt(input_data, tools_prompt=tools_prompt, tools=_mcp_tools)
|
|
@@ -815,10 +822,10 @@ class FlatAgent:
|
|
|
815
822
|
if key not in _KNOWN_MODEL_FIELDS and key not in params and value is not None:
|
|
816
823
|
params[key] = value
|
|
817
824
|
|
|
818
|
-
# Forward session_id
|
|
819
|
-
#
|
|
820
|
-
if self._backend == "codex" and
|
|
821
|
-
params["session_id"] =
|
|
825
|
+
# Forward machine-provided session_id into Codex params so prompt_cache_key
|
|
826
|
+
# is set for this request.
|
|
827
|
+
if self._backend == "codex" and codex_session_id and "session_id" not in params:
|
|
828
|
+
params["session_id"] = codex_session_id
|
|
822
829
|
|
|
823
830
|
# Add tools if available
|
|
824
831
|
if _external_tools:
|
|
@@ -884,6 +891,22 @@ class FlatAgent:
|
|
|
884
891
|
finish_reason = self._extract_finish_reason(response)
|
|
885
892
|
if finish_reason:
|
|
886
893
|
monitor.metrics["finish_reason"] = finish_reason.value
|
|
894
|
+
|
|
895
|
+
# Debug session continuity for codex prompt caching.
|
|
896
|
+
if self._backend == "codex":
|
|
897
|
+
request_meta = getattr(response, "_request_meta", {}) or {}
|
|
898
|
+
request_headers = request_meta.get("headers") if isinstance(request_meta, dict) else {}
|
|
899
|
+
if not isinstance(request_headers, dict):
|
|
900
|
+
request_headers = {}
|
|
901
|
+
session_header = request_headers.get("session_id")
|
|
902
|
+
prompt_cache_key = request_meta.get("prompt_cache_key") if isinstance(request_meta, dict) else None
|
|
903
|
+
logger.info(
|
|
904
|
+
"Codex request debug: session_id=%s prompt_cache_key=%s finish_reason=%s cache_read_tokens=%s",
|
|
905
|
+
session_header,
|
|
906
|
+
prompt_cache_key,
|
|
907
|
+
finish_reason.value if finish_reason else None,
|
|
908
|
+
usage_info.cache_read_tokens if usage_info else 0,
|
|
909
|
+
)
|
|
887
910
|
|
|
888
911
|
# Extract rate limit headers from successful response
|
|
889
912
|
response_headers = extract_headers_from_response(response)
|
|
@@ -147,6 +147,7 @@ class CodexClient:
|
|
|
147
147
|
"url": request_url,
|
|
148
148
|
"headers": self._redact_request_headers(headers),
|
|
149
149
|
"retries_used": retries_used,
|
|
150
|
+
"prompt_cache_key": session_id,
|
|
150
151
|
}
|
|
151
152
|
return result
|
|
152
153
|
except CodexHTTPError as first_error:
|
|
@@ -184,6 +185,7 @@ class CodexClient:
|
|
|
184
185
|
"url": request_url,
|
|
185
186
|
"headers": self._redact_request_headers(retry_headers),
|
|
186
187
|
"retries_used": retries_used,
|
|
188
|
+
"prompt_cache_key": session_id,
|
|
187
189
|
}
|
|
188
190
|
return result
|
|
189
191
|
|
|
@@ -365,14 +367,32 @@ class CodexClient:
|
|
|
365
367
|
response_obj = event.get("response") if isinstance(event.get("response"), dict) else {}
|
|
366
368
|
result.status = str(response_obj.get("status")) if response_obj.get("status") else None
|
|
367
369
|
usage_obj = response_obj.get("usage") if isinstance(response_obj.get("usage"), dict) else {}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
current_input_tokens = int(usage_obj.get("input_tokens") or 0)
|
|
371
|
+
current_output_tokens = int(usage_obj.get("output_tokens") or 0)
|
|
372
|
+
current_total_tokens = int(
|
|
373
|
+
usage_obj.get("total_tokens") or (current_input_tokens + current_output_tokens)
|
|
374
|
+
)
|
|
375
|
+
current_cached_tokens = int(
|
|
372
376
|
(usage_obj.get("input_tokens_details") or {}).get("cached_tokens")
|
|
373
377
|
if isinstance(usage_obj.get("input_tokens_details"), dict)
|
|
374
378
|
else 0
|
|
375
379
|
)
|
|
380
|
+
|
|
381
|
+
# Some payloads emit both response.completed and response.done with
|
|
382
|
+
# different usage fidelity. Preserve best-known values instead of
|
|
383
|
+
# letting a later sparse event overwrite cache metrics with zeros.
|
|
384
|
+
previous_usage = result.usage
|
|
385
|
+
if previous_usage is not None:
|
|
386
|
+
input_tokens = max(previous_usage.input_tokens, current_input_tokens)
|
|
387
|
+
output_tokens = max(previous_usage.output_tokens, current_output_tokens)
|
|
388
|
+
total_tokens = max(previous_usage.total_tokens, current_total_tokens)
|
|
389
|
+
cached_tokens = max(previous_usage.cached_tokens, current_cached_tokens)
|
|
390
|
+
else:
|
|
391
|
+
input_tokens = current_input_tokens
|
|
392
|
+
output_tokens = current_output_tokens
|
|
393
|
+
total_tokens = current_total_tokens
|
|
394
|
+
cached_tokens = current_cached_tokens
|
|
395
|
+
|
|
376
396
|
result.usage = CodexUsage(
|
|
377
397
|
input_tokens=input_tokens,
|
|
378
398
|
output_tokens=output_tokens,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|