yunfengzhou-hub commented on code in PR #1268:
URL: https://github.com/apache/flink-agents/pull/1268#discussion_r4300864107


##########
docs/content/docs/development/multi-agent/subagents.md:
##########
@@ -307,30 +443,854 @@ parent.addResource(
                                 + "\"required\":[\"diff\"]}")
                 .build());
 ```
+{{< /tab >}}
+
+{{< /tabs >}}
+
+The framework does not check the schema against the prompt. A field the prompt 
does
+not use is ignored, and a placeholder no field fills is left in the prompt as 
literal
+text. So keep the two in step when you change either.
+
+### External: write a setup class
+
+An external sub-agent has no plan of its own, and it is not compiled into the
+parent's. The work happens in your own code or in a remote agent service. The 
parent
+only submits to it and waits for the outcome. The framework cannot perform 
that work
+for you, because it does not know your protocol. So you write the part that 
performs
+one invocation, and the framework supplies everything around it. It runs your 
code
+under durable execution, and after a failover it replays the recorded result 
instead
+of calling your code again.
+
+What you write is a setup class. Its only job is to carry out one invocation, 
so it
+declares no actions and no events of its own. It extends a framework base 
class and
+implements the methods that class declares.
+
+Registration names the setup class in a descriptor, and both languages 
construct the
+setup from the descriptor at runtime. Registering a setup instance instead is
+rejected.
+
+The invocation itself is carried out in one of two modes, and which one you 
write
+follows from your remote interface. When one request returns the result, write 
a
+*deferred* setup. You own the whole interaction, and the framework only holds 
it back
+until the caller asks for the result. When the remote instead hands back a run 
that
+you later query for status and result, write an *async (pub/sub)* setup. The 
base
+class owns that composition of publishing, polling, and fetching, and you 
supply the
+transport calls it is built from.
+
+#### Deferred execution
+
+A deferred setup sends nothing when the caller submits. It only registers the
+invocation. The request goes out when the caller first awaits the result. So a 
call
+that is cancelled instead never issues its request.
+
+What you write is the interaction itself, in the `prepare` method of your 
setup class.
+`prepare` runs once per invocation and returns the durable call that carries 
it. The
+example is one blocking request, and whatever else your call does is yours to 
decide,
+because the framework does not know your protocol.
 
+The framework assigns `session_id` and `call_id` before it calls `prepare`, 
and they
+are the only values that a replay reproduces. The durable id you build from 
them is
+the key that recovery matches a recorded result against. When the key matches, 
your
+call is not run again. So build the key from those two values alone. Anything 
else in
+it, a timestamp for instance, makes a replay look up a different key and run 
the work
+a second time. Passing the same values to your own remote lets it recognize a
+re-issued request as the same one.
+
+The reconciler is optional. Omitting it leaves one crash window uncovered, and
+[Durability and failover](#durability-and-failover) describes that window. 
Supply one
+when the work cannot be repeated.
+
+{{< tabs "Supply a Reconciler" >}}
+
+{{< tab "Python" >}}
 ```python
-reviewer = ReActAgent(
-    chat_model=chat_model_descriptor,
-    prompt=Prompt.from_text(
-        "Review the following code diff and report any problems:\n\n{diff}"
+def prepare(
+    self, ctx: RunnerContext, prompt: Any, session_id: str, call_id: str
+) -> PreparedTriple:
+    key = f"{session_id}#{call_id}"
+
+    def call() -> SubagentResult:
+        return SubagentResult.ok(post_review(self.endpoint, prompt, key))
+
+    # Consulted only during recovery, when this call is revisited and no 
result was
+    # recorded for it. Return the recovered outcome, or raise the recovered 
failure.
+    # It takes no arguments.
+    def reconcile() -> SubagentResult:
+        # fetch_review_by_key is your own lookup; not part of Flink Agents.
+        found = fetch_review_by_key(self.endpoint, key)
+        if found is None:
+            raise RuntimeError("the review service has no record of this call")

Review Comment:
   Fixed in these tabs. The comments now say raising here fails the action, 
which is what How failures surface already claimed, so the example and that 
section no longer disagree.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to