Class: Agent::SessionContext::Summarizers::Codex
- Inherits:
-
Object
- Object
- Agent::SessionContext::Summarizers::Codex
- Includes:
- CommandExecutionPolicy
- Defined in:
- lib/agent/session_context/summarizers/codex.rb
Constant Summary collapse
- MAX_OUTPUT_BYTES =
1_048_576
Instance Method Summary collapse
- #call(prompt:, schema:) ⇒ Object
-
#initialize(runner: nil, timeout_seconds: Config::DEFAULT_TIMEOUT_SECONDS) ⇒ Codex
constructor
A new instance of Codex.
- #name ⇒ Object
Constructor Details
#initialize(runner: nil, timeout_seconds: Config::DEFAULT_TIMEOUT_SECONDS) ⇒ Codex
Returns a new instance of Codex.
17 18 19 20 21 22 23 24 |
# File 'lib/agent/session_context/summarizers/codex.rb', line 17 def initialize(runner: nil, timeout_seconds: Config::DEFAULT_TIMEOUT_SECONDS) initialize_command_execution_policy( runner:, timeout_seconds:, max_output_bytes: MAX_OUTPUT_BYTES, provider_env_keys: PROVIDER_ENV_KEYS ) end |
Instance Method Details
#call(prompt:, schema:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/agent/session_context/summarizers/codex.rb', line 30 def call(prompt:, schema:) Tempfile.create(["agent-context-codex-schema", ".json"]) do |schema_file| schema_file.write(JSON.generate(schema)) schema_file.flush Tempfile.create(["agent-context-codex-output", ".json"]) do |output_file| stdout, stderr, status = run_command!( prompt:, argv: command_argv(schema_path: schema_file.path, output_path: output_file.path) ) fail_command!(stdout:, stderr:, status:) unless status.success? payload = (output_file.path, stdout:, stderr:) normalize_json!(payload, source: "last message", stdout:, stderr:) end end end |
#name ⇒ Object
26 27 28 |
# File 'lib/agent/session_context/summarizers/codex.rb', line 26 def name :codex end |