fix: python openai agent sdk integration fix#83
fix: python openai agent sdk integration fix#83Nightingalelyy wants to merge 6 commits intorespanai:mainfrom
Conversation
fix the span_type, serializing, usage count of openai agent sdk integration, create tests for openai agent sdk integration
Greptile SummaryThis PR fixes several issues in the OpenAI Agents SDK integration: corrects Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Trace / Span[Any]"] --> B{isinstance Trace?}
B -- yes --> C["Return root log\n(trace_id, name, LOG_TYPE_AGENT)"]
B -- no --> D{isinstance SpanImpl?}
D -- no --> E["Return None"]
D -- yes --> F["Build base RespanTextLogParams\n(ids, timestamps, error fields)"]
F --> G{span_data type?}
G -- ResponseSpanData --> H["_response_data_to_respan_log\n(Responses API → Chat Completions format,\nusage: input_tokens / output_tokens)"]
G -- FunctionSpanData --> I["_function_data_to_respan_log\n(LOG_TYPE_TOOL, span_tools)"]
G -- GenerationSpanData --> J["_generation_data_to_respan_log\n(prompt_tokens / input_tokens fallback)"]
G -- HandoffSpanData --> K["_handoff_data_to_respan_log\n(from_agent → to_agent)"]
G -- AgentSpanData --> L["_agent_data_to_respan_log\n(LOG_TYPE_AGENT, span_workflow_name)"]
G -- GuardrailSpanData --> M["_guardrail_data_to_respan_log\n(has_warnings, warnings_dict)"]
G -- CustomSpanData --> N["_custom_data_to_respan_log\n(metadata + passthrough keys)"]
G -- unknown --> O["Log warning, return None"]
H & I & J & K & L & M & N --> P["model_dump(mode='json')"]
P --> Q{Caller}
Q -- RespanSpanExporter --> R["HTTP POST to Respan backend\n(with retry + backoff)"]
Q -- LocalSpanCollector --> S["_traces[trace_id].append(data)\n(Trace record inserted at index 0)"]
Last reviewed commit: 6dd1b0b |
...an-exporter-openai-agents/src/respan_exporter_openai_agents/respan_openai_agents_exporter.py
Outdated
Show resolved
Hide resolved
…s.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…openai_agents/respan_openai_agents_exporter.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@greptileai I fixed the problem and add test, please review |
...an-exporter-openai-agents/src/respan_exporter_openai_agents/respan_openai_agents_exporter.py
Outdated
Show resolved
Hide resolved
|
@greptileai problem fixed. review |
| val = getattr(obj, key, None) | ||
| if val is None and isinstance(obj, dict): | ||
| val = obj.get(key, default) | ||
| return val if val is not None else default No newline at end of file |
There was a problem hiding this comment.
safe_attr cannot distinguish an explicit None value from a missing key
Because both getattr(obj, key, None) and obj.get(key, default) map to None for a stored None value, the final guard return val if val is not None else default always substitutes default when the stored value is None. For callers that need to detect an explicitly-set None (as opposed to an absent key), there is no way to do so — they always receive default back instead.
This is a documented, tested design choice (see test_none_value_returns_default), but it is worth keeping in mind when using safe_attr in contexts where None is a meaningful value (e.g. response.instructions = None intentionally overrides a default). If that distinction ever matters, callers should fall back to direct attribute/key access rather than safe_attr.
fix the span_type, serializing, usage count of openai agent sdk integration, create tests for openai agent sdk integration