Skip to content

Commit f563df6

Browse files
authored
feat: adding heading identifier to improve linkability (#587)
Fixes: #109
1 parent 90b43a9 commit f563df6

16 files changed

+76
-76
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ share your patches and improvements with the project.
77

88
Before you contribute, please take a moment to review the following:
99

10-
### 1. Sign our Contributor License Agreement
10+
### 1. Sign our Contributor License Agreement { #sign-our-contributor-license-agreement }
1111

1212
Contributions to this project must be accompanied by a
1313
[Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
@@ -21,7 +21,7 @@ was for a different project), you probably don't need to do it again.
2121
Visit <https://cla.developers.google.com/> to see your current agreements or to
2222
sign a new one.
2323

24-
### 2. Review Community Guidelines
24+
### 2. Review Community Guidelines { #review-community-guidelines }
2525

2626
We adhere to [Google's Open Source Community Guidelines](https://opensource.google/conduct/).
2727
Please familiarize yourself with these guidelines to ensure a positive and

docs/a2a/quickstart-consuming.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The A2A Basic sample consists of:
2727

2828
In the a2a_basic example, you will first need to expose the `check_prime_agent` via an A2A server, so that the local root agent can use it.
2929

30-
### 1. Getting the Sample Code
30+
### 1. Getting the Sample Code { #getting-the-sample-code }
3131

3232
First, make sure you have the necessary dependencies installed:
3333

@@ -68,7 +68,7 @@ a2a_basic/
6868
- **`agent.json`**: Agent card of the A2A agent
6969
- **`check_prime(nums: list[int])`**: Prime number checking algorithm
7070

71-
### 2. Start the Remote Prime Agent server
71+
### 2. Start the Remote Prime Agent server { #start-the-remote-prime-agent-server }
7272

7373
To show how your ADK agent can consume a remote agent via A2A, you'll first need to start a remote agent server, which will host the prime agent (under `check_prime_agent`).
7474

@@ -96,7 +96,7 @@ INFO: Application startup complete.
9696
INFO: Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)
9797
```
9898

99-
### 3. Look out for the required agent card (`agent.json`) of the remote agent
99+
### 3. Look out for the required agent card (`agent.json`) of the remote agent { #look-out-for-the-required-agent-card-agent-json-of-the-remote-agent }
100100

101101
A2A Protocol requires that each agent must have an agent card that describes what it does.
102102

@@ -129,7 +129,7 @@ In the sample, the `check_prime_agent` already has an agent card provided:
129129

130130
In ADK, you can use a `to_a2a(root_agent)` wrapper which automatically generates an agent card for you. If you're interested in learning more about how to expose your existing agent so others can use it, then please look at the [A2A Quickstart (Exposing)](quickstart-exposing.md) tutorial.
131131

132-
### 4. Run the Main (Consuming) Agent
132+
### 4. Run the Main (Consuming) Agent { #run-the-main-consuming-agent }
133133

134134
```bash
135135
# In a separate terminal, run the adk web server

docs/a2a/quickstart-exposing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ The `to_a2a()` function will even auto-generate an agent card in-memory behind-t
6565

6666
Now let's dive into the sample code.
6767

68-
### 1. Getting the Sample Code
68+
### 1. Getting the Sample Code { #getting-the-sample-code }
6969

7070
First, make sure you have the necessary dependencies installed:
7171

@@ -103,7 +103,7 @@ a2a_root/
103103
- **`root_agent`**: The main agent with comprehensive instructions
104104
- **`a2a_app`**: The A2A application created using `to_a2a()` utility
105105

106-
### 2. Start the Remote A2A Agent server
106+
### 2. Start the Remote A2A Agent server { #start-the-remote-a2a-agent-server }
107107

108108
You can now start the remote agent server, which will host the `a2a_app` within the hello_world agent:
109109

@@ -125,7 +125,7 @@ INFO: Application startup complete.
125125
INFO: Uvicorn running on http://localhost:8001 (Press CTRL+C to quit)
126126
```
127127

128-
### 3. Check that your remote agent is running
128+
### 3. Check that your remote agent is running { #check-that-your-remote-agent-is-running }
129129

130130
You can check that your agent is up and running by visiting the agent card that was auto-generated earlier as part of your `to_a2a()` function in `a2a_root/remote_a2a/hello_world/agent.py`:
131131

@@ -137,7 +137,7 @@ You should see the contents of the agent card, which should look like:
137137
{"capabilities":{},"defaultInputModes":["text/plain"],"defaultOutputModes":["text/plain"],"description":"hello world agent that can roll a dice of 8 sides and check prime numbers.","name":"hello_world_agent","protocolVersion":"0.2.6","skills":[{"description":"hello world agent that can roll a dice of 8 sides and check prime numbers. \n I roll dice and answer questions about the outcome of the dice rolls.\n I can roll dice of different sizes.\n I can use multiple tools in parallel by calling functions in parallel(in one request and in one round).\n It is ok to discuss previous dice roles, and comment on the dice rolls.\n When I are asked to roll a die, I must call the roll_die tool with the number of sides. Be sure to pass in an integer. Do not pass in a string.\n I should never roll a die on my own.\n When checking prime numbers, call the check_prime tool with a list of integers. Be sure to pass in a list of integers. I should never pass in a string.\n I should not check prime numbers before calling the tool.\n When I are asked to roll a die and check prime numbers, I should always make the following two function calls:\n 1. I should first call the roll_die tool to get a roll. Wait for the function response before calling the check_prime tool.\n 2. After I get the function response from roll_die tool, I should call the check_prime tool with the roll_die result.\n 2.1 If user asks I to check primes based on previous rolls, make sure I include the previous rolls in the list.\n 3. When I respond, I must include the roll_die result from step 1.\n I should always perform the previous 3 steps when asking for a roll and checking prime numbers.\n I should not rely on the previous history on prime results.\n ","id":"hello_world_agent","name":"model","tags":["llm"]},{"description":"Roll a die and return the rolled result.\n\nArgs:\n sides: The integer number of sides the die has.\n tool_context: the tool context\nReturns:\n An integer of the result of rolling the die.","id":"hello_world_agent-roll_die","name":"roll_die","tags":["llm","tools"]},{"description":"Check if a given list of numbers are prime.\n\nArgs:\n nums: The list of numbers to check.\n\nReturns:\n A str indicating which number is prime.","id":"hello_world_agent-check_prime","name":"check_prime","tags":["llm","tools"]}],"supportsAuthenticatedExtendedCard":false,"url":"http://localhost:8001","version":"0.0.1"}
138138
```
139139

140-
### 4. Run the Main (Consuming) Agent
140+
### 4. Run the Main (Consuming) Agent { #run-the-main-consuming-agent }
141141

142142
Now that your remote agent is running, you can launch the dev UI and select "a2a_root" as your agent.
143143

docs/agents/custom-agents.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Let's illustrate the power of custom agents with an example pattern: a multi-sta
141141

142142
---
143143

144-
### Part 1: Simplified custom agent Initialization
144+
### Part 1: Simplified custom agent Initialization { #part-1-simplified-custom-agent-initialization }
145145

146146
=== "Python"
147147

@@ -160,7 +160,7 @@ Let's illustrate the power of custom agents with an example pattern: a multi-sta
160160
```
161161
---
162162

163-
### Part 2: Defining the Custom Execution Logic
163+
### Part 2: Defining the Custom Execution Logic { #part-2-defining-the-custom-execution-logic }
164164

165165
=== "Python"
166166

@@ -193,7 +193,7 @@ Let's illustrate the power of custom agents with an example pattern: a multi-sta
193193

194194
---
195195

196-
### Part 3: Defining the LLM Sub-Agents
196+
### Part 3: Defining the LLM Sub-Agents { #part-3-defining-the-llm-sub-agents }
197197

198198
These are standard `LlmAgent` definitions, responsible for specific tasks. Their `output key` parameter is crucial for placing results into the `session.state` where other agents or the custom orchestrator can access them.
199199

@@ -214,7 +214,7 @@ These are standard `LlmAgent` definitions, responsible for specific tasks. Their
214214

215215
---
216216

217-
### Part 4: Instantiating and Running the custom agent
217+
### Part 4: Instantiating and Running the custom agent { #part-4-instantiating-and-running-the-custom-agent }
218218

219219
Finally, you instantiate your `StoryFlowAgent` and use the `Runner` as usual.
220220

docs/agents/multi-agents.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ You can compose various types of agents derived from `BaseAgent` to build these
1212

1313
The following sections detail the core ADK primitives—such as agent hierarchy, workflow agents, and interaction mechanisms—that enable you to construct and manage these multi-agent systems effectively.
1414

15-
## 1. ADK Primitives for Agent Composition
15+
## 1. ADK Primitives for Agent Composition { #adk-primitives-for-agent-composition }
1616

1717
ADK provides core building blocks—primitives—that enable you to structure and manage interactions within your multi-agent system.
1818

1919
!!! Note
2020
The specific parameters or method names for the primitives may vary slightly by SDK language (e.g., `sub_agents` in Python, `subAgents` in Java). Refer to the language-specific API documentation for details.
2121

22-
### 1.1. Agent Hierarchy (Parent agent, Sub Agents)
22+
### 1.1. Agent Hierarchy (Parent agent, Sub Agents) { #agent-hierarchy-parent-agent-sub-agents }
2323

2424
The foundation for structuring multi-agent systems is the parent-child relationship defined in `BaseAgent`.
2525

@@ -77,7 +77,7 @@ The foundation for structuring multi-agent systems is the parent-child relations
7777
// assert taskDoer.parentAgent().equals(coordinator);
7878
```
7979

80-
### 1.2. Workflow Agents as Orchestrators
80+
### 1.2. Workflow Agents as Orchestrators { #workflow-agents-as-orchestrators }
8181

8282
ADK includes specialized agents derived from `BaseAgent` that don't perform tasks themselves but orchestrate the execution flow of their `sub_agents`.
8383

@@ -223,7 +223,7 @@ ADK includes specialized agents derived from `BaseAgent` that don't perform task
223223
// until Checker escalates (state.get("status") == "completed") or 10 iterations pass.
224224
```
225225

226-
### 1.3. Interaction & Communication Mechanisms
226+
### 1.3. Interaction & Communication Mechanisms { #interaction-communication-mechanisms }
227227

228228
Agents within a system often need to exchange data or trigger actions in one another. ADK facilitates this through:
229229

@@ -444,7 +444,7 @@ Allows an [`LlmAgent`](llm-agents.md) to treat another `BaseAgent` instance as a
444444

445445
These primitives provide the flexibility to design multi-agent interactions ranging from tightly coupled sequential workflows to dynamic, LLM-driven delegation networks.
446446

447-
## 2. Common Multi-Agent Patterns using ADK Primitives
447+
## 2. Common Multi-Agent Patterns using ADK Primitives { #common-multi-agent-patterns-using-adk-primitives }
448448

449449
By combining ADK's composition primitives, you can implement various established patterns for multi-agent collaboration.
450450

docs/callbacks/design-patterns-and-best-practices.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ Callbacks offer powerful hooks into the agent lifecycle. Here are common design
66

77
These patterns demonstrate typical ways to enhance or control agent behavior using callbacks:
88

9-
### 1. Guardrails & Policy Enforcement
9+
### 1. Guardrails & Policy Enforcement { #guardrails-policy-enforcement }
1010

1111
* **Pattern:** Intercept requests before they reach the LLM or tools to enforce rules.
1212
* **How:** Use `before_model_callback` to inspect the `LlmRequest` prompt or `before_tool_callback` to inspect tool arguments. If a policy violation is detected (e.g., forbidden topics, profanity), return a predefined response (`LlmResponse` or `dict`/ `Map`) to block the operation and optionally update `context.state` to log the violation.
1313
* **Example:** A `before_model_callback` checks `llm_request.contents` for sensitive keywords and returns a standard "Cannot process this request" `LlmResponse` if found, preventing the LLM call.
1414

15-
### 2. Dynamic State Management
15+
### 2. Dynamic State Management { #dynamic-state-management }
1616

1717
* **Pattern:** Read from and write to session state within callbacks to make agent behavior context-aware and pass data between steps.
1818
* **How:** Access `callback_context.state` or `tool_context.state`. Modifications (`state['key'] = value`) are automatically tracked in the subsequent `Event.actions.state_delta` for persistence by the `SessionService`.
1919
* **Example:** An `after_tool_callback` saves a `transaction_id` from the tool's result to `tool_context.state['last_transaction_id']`. A later `before_agent_callback` might read `state['user_tier']` to customize the agent's greeting.
2020

21-
### 3. Logging and Monitoring
21+
### 3. Logging and Monitoring { #logging-and-monitoring }
2222

2323
* **Pattern:** Add detailed logging at specific lifecycle points for observability and debugging.
2424
* **How:** Implement callbacks (e.g., `before_agent_callback`, `after_tool_callback`, `after_model_callback`) to print or send structured logs containing information like agent name, tool name, invocation ID, and relevant data from the context or arguments.
2525
* **Example:** Log messages like `INFO: [Invocation: e-123] Before Tool: search_api - Args: {'query': 'ADK'}`.
2626

27-
### 4. Caching
27+
### 4. Caching { #caching }
2828

2929
* **Pattern:** Avoid redundant LLM calls or tool executions by caching results.
3030
* **How:** In `before_model_callback` or `before_tool_callback`, generate a cache key based on the request/arguments. Check `context.state` (or an external cache) for this key. If found, return the cached `LlmResponse` or result directly, skipping the actual operation. If not found, allow the operation to proceed and use the corresponding `after_` callback (`after_model_callback`, `after_tool_callback`) to store the new result in the cache using the key.
3131
* **Example:** `before_tool_callback` for `get_stock_price(symbol)` checks `state[f"cache:stock:{symbol}"]`. If present, returns the cached price; otherwise, allows the API call and `after_tool_callback` saves the result to the state key.
3232

33-
### 5. Request/Response Modification
33+
### 5. Request/Response Modification { #request-response-modification }
3434

3535
* **Pattern:** Alter data just before it's sent to the LLM/tool or just after it's received.
3636
* **How:**
@@ -40,21 +40,21 @@ These patterns demonstrate typical ways to enhance or control agent behavior usi
4040
* `after_tool_callback`: Modify the `tool_response` dictionary (or Map in Java).
4141
* **Example:** `before_model_callback` appends "User language preference: Spanish" to `llm_request.config.system_instruction` if `context.state['lang'] == 'es'`.
4242

43-
### 6. Conditional Skipping of Steps
43+
### 6. Conditional Skipping of Steps { #conditional-skipping-of-steps }
4444

4545
* **Pattern:** Prevent standard operations (agent run, LLM call, tool execution) based on certain conditions.
4646
* **How:** Return a value from a `before_` callback (`Content` from `before_agent_callback`, `LlmResponse` from `before_model_callback`, `dict` from `before_tool_callback`). The framework interprets this returned value as the result for that step, skipping the normal execution.
4747
* **Example:** `before_tool_callback` checks `tool_context.state['api_quota_exceeded']`. If `True`, it returns `{'error': 'API quota exceeded'}`, preventing the actual tool function from running.
4848

49-
### 7. Tool-Specific Actions (Authentication & Summarization Control)
49+
### 7. Tool-Specific Actions (Authentication & Summarization Control) { #tool-specific-actions-authentication-summarization-control }
5050

5151
* **Pattern:** Handle actions specific to the tool lifecycle, primarily authentication and controlling LLM summarization of tool results.
5252
* **How:** Use `ToolContext` within tool callbacks (`before_tool_callback`, `after_tool_callback`).
5353
* **Authentication:** Call `tool_context.request_credential(auth_config)` in `before_tool_callback` if credentials are required but not found (e.g., via `tool_context.get_auth_response` or state check). This initiates the auth flow.
5454
* **Summarization:** Set `tool_context.actions.skip_summarization = True` if the raw dictionary output of the tool should be passed back to the LLM or potentially displayed directly, bypassing the default LLM summarization step.
5555
* **Example:** A `before_tool_callback` for a secure API checks for an auth token in state; if missing, it calls `request_credential`. An `after_tool_callback` for a tool returning structured JSON might set `skip_summarization = True`.
5656

57-
### 8. Artifact Handling
57+
### 8. Artifact Handling { #artifact-handling }
5858

5959
* **Pattern:** Save or load session-related files or large data blobs during the agent lifecycle.
6060
* **How:** Use `callback_context.save_artifact` / `await tool_context.save_artifact` to store data (e.g., generated reports, logs, intermediate data). Use `load_artifact` to retrieve previously stored artifacts. Changes are tracked via `Event.actions.artifact_delta`.

docs/contributing-guide.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ Thank you for your interest in contributing to the Agent Development Kit (ADK)!
22

33
This guide provides information on how to get involved.
44

5-
## 1. [`google/adk-python`](https://github.com/google/adk-python)
5+
## 1. [`google/adk-python`](https://github.com/google/adk-python) { #google-adk-python }
66

77
Contains the core Python library source code.
88

9-
## 2. [`google/adk-java`](https://github.com/google/adk-java)
9+
## 2. [`google/adk-java`](https://github.com/google/adk-java) { #google-adk-java }
1010

1111
Contains the core Java library source code.
1212

13-
## 3. [`google/adk-docs`](https://github.com/google/adk-docs)
13+
## 3. [`google/adk-docs`](https://github.com/google/adk-docs) { #google-adk-docs }
1414

1515
Contains the source for the documentation site you are currently reading.
1616

17-
## 4. [`google/adk-web`](https://github.com/google/adk-web)
17+
## 4. [`google/adk-web`](https://github.com/google/adk-web) { #google-adk-web }
1818

1919
Contains the source for the `adk web` dev UI.
2020

@@ -54,28 +54,28 @@ This is the primary place for:
5454

5555
There are several ways you can contribute to the ADK:
5656

57-
### 1. Reporting Issues (Bugs & Errors)
57+
### 1. Reporting Issues (Bugs & Errors) { #reporting-issues-bugs-errors }
5858

5959
If you find a bug in the framework or an error in the documentation:
6060

6161
* **Framework Bugs:** Open an issue in [`google/adk-python`](https://github.com/google/adk-python/issues/new) or in [`google/adk-java`](https://github.com/google/adk-java/issues/new)
6262
* **Documentation Errors:** [Open an issue in `google/adk-docs` (use bug template)](https://github.com/google/adk-docs/issues/new?template=bug_report.md)
6363

64-
### 2. Suggesting Enhancements
64+
### 2. Suggesting Enhancements { #suggesting-enhancements }
6565

6666
Have an idea for a new feature or an improvement to an existing one?
6767

6868
* **Framework Enhancements:** Open an issue in [`google/adk-python`](https://github.com/google/adk-python/issues/new) or in [`google/adk-java`](https://github.com/google/adk-java/issues/new)
6969
* **Documentation Enhancements:** [Open an issue in `google/adk-docs`](https://github.com/google/adk-docs/issues/new)
7070

71-
### 3. Improving Documentation
71+
### 3. Improving Documentation { #improving-documentation }
7272

7373
Found a typo, unclear explanation, or missing information? Submit your changes directly:
7474

7575
* **How:** Submit a Pull Request (PR) with your suggested improvements.
7676
* **Where:** [Create a Pull Request in `google/adk-docs`](https://github.com/google/adk-docs/pulls)
7777

78-
### 4. Writing Code
78+
### 4. Writing Code { #writing-code }
7979

8080
Help fix bugs, implement new features or contribute code samples for the documentation:
8181

0 commit comments

Comments
 (0)