File size: 1,097 Bytes
5f25733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Process an untrusted notification within a task authorized by the user."""

import sys
from pathlib import Path

_EXAMPLES_ROOT = Path(__file__).resolve().parents[1]
if str(_EXAMPLES_ROOT) not in sys.path:
    sys.path.insert(0, str(_EXAMPLES_ROOT))

from _bootstrap import ensure_local_sdk_src, runtime_config

ensure_local_sdk_src()

from openai_codex import Codex, ExternalMessage, Sandbox

with Codex(config=runtime_config()) as codex:
    thread = codex.thread_start(sandbox=Sandbox.read_only)
    thread.run(
        "When deployment notifications arrive, summarize their status and suggest "
        "what I should check. Do not change files or deploy anything."
    )

    # External content has tool authority; it does not supply user permission.
    result = thread.run(
        ExternalMessage(
            tool_name="notifications",
            namespace="slack",
            content="Staging deployment failed: the health check returned HTTP 503.",
        ),
        source="slack_notification",
    )
    print("status:", result.status)
    print("text:", result.final_response)