mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Address comments
This commit is contained in:
@@ -173,7 +173,7 @@ Finally we have `VS_CODE_EXTENSION_PORT` which you can set to a port, which can
|
||||
|
||||
The framework will emit observability data when the `ENABLE_INSTRUMENTATION` environment variable is set to `true`. If both are `true` then it will also emit sensitive information. When these are not set, or set to false, you can use the `enable_instrumentation()` function from the `agent_framework.observability` module to turn on instrumentation programmatically. This is useful when you want to control this via code instead of environment variables.
|
||||
|
||||
> **Note**: Sensitive information includes prompts, responses, and more, and should only be enabled in a development or test environment. It is not recommended to enable this in production environments as it may expose sensitive data. Enabling this will automatically enable instrumentation if it is not already enabled.
|
||||
> **Note**: Sensitive information includes prompts, responses, and more, and should only be enabled in a development or test environment. It is not recommended to enable this in production environments as it may expose sensitive data.
|
||||
|
||||
The two other variables, `ENABLE_CONSOLE_EXPORTERS` and `VS_CODE_EXTENSION_PORT`, are used to configure where the observability data is sent. Those are only activated when calling `configure_otel_providers()`.
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.Python
|
||||
.env
|
||||
@@ -3,4 +3,5 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.Python
|
||||
.env
|
||||
@@ -3,4 +3,5 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.Python
|
||||
.env
|
||||
+2
-1
@@ -3,4 +3,5 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.Python
|
||||
.env
|
||||
+2
-1
@@ -3,4 +3,5 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.Python
|
||||
.env
|
||||
@@ -4,6 +4,7 @@ __pycache__
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.env
|
||||
|
||||
# Local-only client tooling and sample data; not needed inside the agent image.
|
||||
resources/
|
||||
|
||||
+2
-1
@@ -3,4 +3,5 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
.Python
|
||||
.env
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
FOUNDRY_PROJECT_ENDPOINT="..."
|
||||
AZURE_AI_MODEL_DEPLOYMENT_NAME="..."
|
||||
ENABLE_INSTRUMENTATION=true
|
||||
ENABLE_SENSITIVE_DATA=true
|
||||
APPLICATIONINSIGHTS_CONNECTION_STRING="..."
|
||||
ENABLE_SENSITIVE_DATA=true
|
||||
+4
-8
@@ -16,11 +16,9 @@ The agent is hosted using the [Agent Framework](https://github.com/microsoft/age
|
||||
|
||||
### Instrumentation
|
||||
|
||||
Agent Framework is [**natively instrumented**](https://learn.microsoft.com/en-us/agent-framework/agents/observability?pivots=programming-language-python) to capture diagnostics and telemetry for agent execution, but it's turned off by default. This sample demonstrates how to enable instrumentation via environment variables in `agent.manifest.yaml` and `anget.yaml`. The relevant environment variables are `ENABLE_INSTRUMENTATION` and `ENABLE_SENSITIVE_DATA`, which can be set to `true` to enable diagnostics and capture sensitive events respectively.
|
||||
Agent Framework is [**natively instrumented**](https://learn.microsoft.com/en-us/agent-framework/agents/observability?pivots=programming-language-python) to capture diagnostics and telemetry for agent execution, but it's turned off by default. This sample demonstrates how to enable instrumentation via environment variables in `agent.manifest.yaml` and `agent.yaml`. The relevant environment variables are `ENABLE_INSTRUMENTATION` and `ENABLE_SENSITIVE_DATA`, which can be set to `true` to enable diagnostics and capture sensitive events respectively.
|
||||
|
||||
Foundry Hosted Agent has built-in observability thus you don't need to set up exporters manually to capture telemetry from your code. The traces, metrics, and logs generated by the agent are automatically collected and made available through Foundry's observability stack via Azure Monitor/Application Insights. The `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable is injected when the agent is deployed to Foundry, however it is still required to be set in your local `.env` file or your environment if you want to run the agent host locally and have telemetry sent to Application Insights from your local environment.
|
||||
|
||||
> Setting `ENABLE_SENSITIVE_DATA` to `true` will automatically enable `ENABLE_INSTRUMENTATION` as well, since capturing sensitive events requires that instrumentation be enabled.
|
||||
Foundry Hosted Agent has built-in observability thus you don't need to set up exporters manually to capture telemetry from your code. The traces, metrics, and logs generated by the agent are automatically collected and made available through Foundry's observability stack via Azure Monitor/Application Insights. The `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable is injected when the agent is deployed to Foundry, however it is still required to be set in your environment if you want to run the agent host locally and have telemetry sent to Application Insights from your local environment.
|
||||
|
||||
## Running the Agent Host
|
||||
|
||||
@@ -28,12 +26,10 @@ Follow the instructions in the [Running the Agent Host Locally](../../README.md#
|
||||
|
||||
## Interacting with the agent
|
||||
|
||||
> Depending on how you run the agent host, you can invoke the agent using `curl` (`Invoke-WebRequest` in PowerShell) or `azd`. Please refer to the [parent README](../../README.md) for more details. Use this README for sample queries you can send to the agent.
|
||||
|
||||
Send a POST request to the server with a JSON body containing an `"input"` field to interact with the agent. For example:
|
||||
> Because the observability exporters are managed by Foundry, this sample must be run using `azd ai agent run`. Run this sample using `python main.py` will not send telemetry to Application Insights.
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8088/responses -H "Content-Type: application/json" -d '{"input": "What is the current weather?"}'
|
||||
azd ai agent run --local "What is the current weather?"
|
||||
```
|
||||
|
||||
A couple of spans will be created for this request from Agent Framework's instrumentation, representing the generation of the response by the agent:
|
||||
|
||||
@@ -16,9 +16,9 @@ from pydantic import Field
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@tool(approval_mode="never_require")
|
||||
@tool(approval_mode="never_require", description="Get the current location of the user.")
|
||||
def get_current_location() -> str:
|
||||
"""Get the current working directory."""
|
||||
"""Get the current location of the agent."""
|
||||
locations = ["New York", "London", "Paris", "Tokyo"]
|
||||
return locations[randint(0, len(locations) - 1)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user