<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Haiyang(Ocean) Li on Medium]]></title>
        <description><![CDATA[Stories by Haiyang(Ocean) Li on Medium]]></description>
        <link>https://medium.com/@haiyangli_38602?source=rss-1088d689308------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lLoiiGLLTnU0qr1uBscUIA.jpeg</url>
            <title>Stories by Haiyang(Ocean) Li on Medium</title>
            <link>https://medium.com/@haiyangli_38602?source=rss-1088d689308------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:01:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haiyangli_38602/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your coding agent’s search came back empty. Was it looking?]]></title>
            <link>https://medium.com/@haiyangli_38602/your-coding-agents-search-came-back-empty-was-it-looking-a27bef439362?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/a27bef439362</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 15:04:29 GMT</pubDate>
            <atom:updated>2026-10-17T15:04:29.488Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEhutvB1KnDjlM8YWMHYjQ.png" /></figure><p>Ask a coding agent whether a function still has callers, or whether a leaked token is gone from the logs, and it runs a search, usually grep over the logs or git grep over the repository. When the search prints a wrong line, the agent or I can see the line is wrong. When the search prints nothing, there is nothing to look at, and exit code 1 reads the same whether the thing is absent or the tool never looked where the thing was. The agent says “not found” and moves on to the next step, which is often a delete.</p><p>My agents ran into a few of these over the past months. On October 12 we reproduced each one on one Mac (macOS 27.2, git 2.55, BSD grep 2.6.0, ripgrep 15.2, the bash 3.2 that ships with macOS). Every example runs in a fresh temporary directory, so you can paste it and get the same thing.</p><h3>A word boundary that matches nothing</h3><p>One file, f.txt, committed to a fresh repository, with four lines: alpha, beta, gamma, alphabet.</p><pre>$ git grep -E &#39;\balpha\b&#39;<br>$ echo $?<br>1</pre><p>It prints nothing and exits 1 without a warning. On this machine \b is not a word boundary in the extended regex that git grep -E uses, so the pattern matches nothing at all. Any of these finds the line:</p><pre>$ git grep -w alpha<br>f.txt:alpha<br>$ git grep -P &#39;\balpha\b&#39;<br>f.txt:alpha<br>$ git grep -E &#39;[[:&lt;:]]alpha[[:&gt;:]]&#39;<br>f.txt:alpha</pre><p>Most regex flavors support \b, so it is the natural thing for an agent to write for a whole-word search. An agent checking &quot;is alpha used anywhere&quot; gets no from the first form, and the answer looks clean.</p><h3>A file the tool chose not to read</h3><p>ripgrep skips whatever .gitignore lists. For searching code that is the right default, and for &quot;does this string appear anywhere in this directory&quot; the wrong one.</p><pre>$ printf &#39;*.log\n&#39; &gt; .gitignore<br>$ printf &#39;token=alpha\n&#39; &gt; app.log<br>$ rg alpha<br>$ echo $?<br>1<br>$ rg --no-ignore alpha<br>app.log:token=alpha</pre><p>Logs are the usual thing to ignore, and logs are where a leaked token ends up.</p><h3>A log with one NUL byte</h3><p>run.log has three lines. The middle one contains alpha, and there is a single NUL byte near the end.</p><pre>$ grep alpha run.log<br>Binary file run.log matches<br>$ grep -I alpha run.log<br>$ echo $?<br>1<br>$ grep -a alpha run.log<br>alpha in the middle</pre><p>Plain grep at least says there is a match. With -I, the flag scripts add to skip binary files, the log disappears: no output, exit 1. -a reads the file as text and prints the line.</p><p>ripgrep behaves the same way in a recursive search. In the directory above, rg --no-ignore alpha printed app.log and said nothing about run.log. rg -uuu alpha reports run.log: binary file matches, and rg --no-ignore -a alpha prints the line itself.</p><h3>A check that never stopped the script</h3><p>This one is no search, and it fails the same way. set -e is supposed to stop a bash script at the first failing command, and it does not apply to a command on the left of &amp;&amp; or ||.</p><pre>$ bash -c &#39;set -e; false &amp;&amp; true; echo &quot;still running after false&quot;&#39;<br>still running after false<br>$ echo $?<br>0</pre><p>An agent that writes its guard as check &amp;&amp; next gets a script that keeps going after the check fails. Put the check on its own line, or end it with || exit 1.</p><h3>What they have in common</h3><p>grep, git grep, ripgrep and bash each did what their defaults say. Where it goes wrong is the reading of an empty result, taking “no lines” as “no such thing” when the command only said “this command, with these defaults, printed no lines”. Someone scrolling the terminal may catch a warning line, but an agent that reads only the exit code acts on the answer right away.</p><p>So any search of ours that can come back empty now also looks for something we know is there, in the same command, through the same path as the real answer. If the known thing doesn’t come back, the search itself is broken and its empty result can’t be used.</p><p>In the NUL-byte case a known line in a clean file comes back fine while run.log is still being skipped, so the known line goes into the same kind of file, in the same directory, read with the same flags:</p><pre>$ printf &#39;KNOWN_PRESENT\n\0&#39; &gt; logs/control.log<br>$ grep -rI -e &#39;the-thing-you-hope-is-gone&#39; -e &#39;KNOWN_PRESENT&#39; logs/<br>$ echo $?<br>1</pre><p>The control is missing from the output, which tells you -I is hiding files with NUL bytes, so the empty result for the real pattern can&#39;t be trusted.</p><p>The set -e case gets the same treatment. Run the guard once against an input that must fail and watch the script stop. If it keeps going, the guard protects nothing.</p><p>When an agent tells us a string is gone from the logs, we ask to see the known line it found with the same command, and until that line shows up we treat the search as not done.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a27bef439362" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LionAG2: Recursive Exploratory Research with AG2 beta — Typed multi-agent handoff]]></title>
            <link>https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-typed-multi-agent-handoff-fb752f9c0265?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb752f9c0265</guid>
            <category><![CDATA[ag2]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[autogen]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Wed, 13 May 2026 19:29:56 GMT</pubDate>
            <atom:updated>2026-05-13T19:41:55.954Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-structured-output-with-response-schema-2-10-83a6f83c47bd">day 2</a> tutorial, we explored how to use <a href="https://www.ag2.ai/">ag2</a> to create structured output. To recap, the agent was granted the <a href="https://exa.ai/">exa</a> search tool and was asked to create a structured output as a Finding with citations.</p><pre>from pydantic import BaseModel<br><br>class Citation(BaseModel):<br>    title: str = Field(description=&quot;The cited work or source.&quot;)<br>    relevance: str = Field(description=&quot;One sentence on why this source supports the finding.&quot;)<br><br>class Finding(BaseModel):<br>    &quot;&quot;&quot;One self-contained research result.&quot;&quot;&quot;<br>    topic: str = Field(description=&quot;The specific aspect of the question this finding addresses.&quot;)<br>    summary: str = Field(description=&quot;2-3 sentences capturing the core mechanism or claim.&quot;)<br>    citations: list[Citation] = Field(description=&quot;Sources behind the summary; emit [] if none.&quot;)<br>    novelty: float = Field(ge=0.0, le=1.0, description=&quot;0 = textbook, 1 = cutting edge.&quot;)</pre><p>The structured output is handy for downstream data manipulation and adding conditions to the agentic workflows. In today’s tutorial, we will look into how to use structured output to create a multi-agent handoff workflow.</p><h3>Setup</h3><pre>import os<br><br>from dotenv import load_dotenv<br>from IPython.display import Markdown, display<br>from pydantic import BaseModel, Field<br><br>from autogen.beta import Agent<br>from autogen.beta.config import OpenAIConfig<br>from autogen.beta.tools import ExaToolkit<br><br>load_dotenv()<br><br>config = OpenAIConfig(<br>    model=&quot;gpt-5.4-mini&quot;,<br>    api_key=os.getenv(&quot;OPENAI_API_KEY&quot;),<br>    base_url=&quot;https://api.openai.com/v1&quot;,<br>)<br>exa_tool = ExaToolkit(api_key=os.getenv(&quot;EXA_API_KEY&quot;))</pre><p>The schema from before was quite straightforward — produce a finding with citations from search results. Let’s add some richer schemas:</p><pre>class OpenQuestion(BaseModel):<br>    question: str = Field(description=&quot;A specific unresolved question surfaced by the survey.&quot;)<br>    novelty: float = Field(<br>        ge=0.0, le=1.0,<br>        description=&quot;0 = well-studied, 1 = barely explored.&quot;,<br>    )<br><br>class Survey(BaseModel):<br>    &quot;&quot;&quot;Surveyor output: landscape of a topic plus open frontiers.&quot;&quot;&quot;<br>    topic: str<br>    overview: str = Field(description=&quot;2-3 sentence summary of the current state of knowledge.&quot;)<br>    key_findings: list[str] = Field(description=&quot;Major established results (3-5 bullets).&quot;)<br>    open_questions: list[OpenQuestion] = Field(<br>        description=&quot;Unresolved questions ranked by novelty. At least 2.&quot;,<br>    )<br><br>class Hypothesis(BaseModel):<br>    &quot;&quot;&quot;Theorist output: one falsifiable claim with a test.&quot;&quot;&quot;<br>    claim: str = Field(description=&quot;One-sentence falsifiable claim.&quot;)<br>    mechanism: str = Field(description=&quot;Why this claim might hold — the causal story.&quot;)<br>    testable_prediction: str = Field(<br>        description=&quot;An observable that would confirm or refute the claim.&quot;<br>    )<br>    confidence: float = Field(ge=0.0, le=1.0, description=&quot;Subjective confidence in the claim.&quot;)<br>    source_question: str = Field(description=&quot;The open question this hypothesis addresses.&quot;)</pre><p>OpenQuestion carries a novelty score, this will become the key signal for deciding which questions are worth drilling deeper into.</p><h3>Pipeline</h3><p>The pipeline today will go as follows:</p><ul><li>a surveyor agent will conduct survey via search tools over literature and produce a survey object with open questions</li><li>for each open question, we will launch one theorist agent will then take to research further and create hypothesis</li></ul><pre>topic = &quot;high-Tc superconductivity&quot;<br><br>surveyor = Agent(<br>    name=&quot;surveyor&quot;,<br>    prompt=(<br>        f&quot;You are a meticulous research surveyor. Search broadly on {topic}&quot;<br>        &quot;, then summarize what is known and what remains open. Be specific &quot;<br>        &quot;about novelty — textbook material is 0.0, active frontiers are 0.7+.&quot;<br>    ),<br>    config=config,<br>    response_schema=Survey,<br>    tools=[exa_tool],<br>)<br><br>survey_reply = await surveyor.ask(<br>    &quot;Survey the current state of high-Tc superconductivity research.&quot;<br>)<br>survey = await survey_reply.content()</pre><p>The survey is a pydantic object of type Survey(BaseModel) as defined above, and now since we have more than one open questions, we can launch parallel theorists to investigate them at the same time.</p><pre>async def hypothesize(question: OpenQuestion, survey=survey) -&gt; Hypothesis:<br>  theorist = Agent(<br>      name=&quot;theorist&quot;,<br>      prompt=(<br>          &quot;You are a theoretical physicist. Given a survey and an open question, &quot;<br>          &quot;produce a precise, falsifiable hypothesis. Be concrete about the &quot;<br>          &quot;mechanism and what experiment would test it.&quot;<br>      ),<br>      config=config,<br>      response_schema=Hypothesis,<br>      tools=[exa_tool],<br>  )<br><br>  theorist_prompt = (<br>      f&quot;Survey topic: {survey.topic}\n&quot;<br>      f&quot;Overview: {survey.overview}\n\n&quot;<br>      f&quot;Key findings:\n&quot;<br>      + &quot;\n&quot;.join(f&quot;- {kf}&quot; for kf in survey.key_findings)<br>      + f&quot;\n\nFocus on this open question (novelty={question.novelty:.2f}):\n&quot;<br>      f&quot;{question.question}\n\n&quot;<br>      f&quot;Produce a falsifiable hypothesis with a concrete testable prediction.&quot;<br>  <br>  hyp_reply = await theorist.ask(theorist_prompt)<br>  return await hyp_reply.content()<br><br>results = await asyncio.gather(*(hypothesize(q) for q in survey.open_questions))</pre><p>Let’s view the result</p><pre>for i, hyp in enumerate(results):<br>    lines = [<br>        f&quot;### Hypothesis {i+1}&quot;,<br>        f&quot;**Claim:** {hyp.claim}&quot;,<br>        f&quot;**Mechanism:** {hyp.mechanism}&quot;,<br>        f&quot;**Test:** {hyp.testable_prediction}&quot;,<br>        f&quot;**Confidence:** {hyp.confidence:.2f}&quot;,<br>        f&quot;**Addresses:** {hyp.source_question}&quot;,<br>    ]<br>    display(Markdown(&quot;\n\n&quot;.join(lines)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wpoknnb7y3OSh1EsA3I6sA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6oEJ4weYBTxmIEpVbfx6Jg.png" /></figure><p>Note there are multiple hypothesis because each open question was processed by one theorist, and this is the basic mechanism of hierarchical multi-agent orchestration.</p><p>In the next tutorial we will introduce the concept of event in ag2, and dive deeper into multi agent orchestration.</p><p>check the notebook <a href="https://github.com/khive-ai/lionag2/blob/main/notebooks/03_multi_agent_handoff.ipynb">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb752f9c0265" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LionAG2: Recursive Exploratory Research with AG2 beta — structured output with response_schema 2/10]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Turn free-text model replies into validated Pydantic objects &#x2014; and why that matters for multi-agent pipelines</p><p class="medium-feed-link"><a href="https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-structured-output-with-response-schema-2-10-83a6f83c47bd?source=rss-1088d689308------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-structured-output-with-response-schema-2-10-83a6f83c47bd?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/83a6f83c47bd</guid>
            <category><![CDATA[pydantic]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[autogen]]></category>
            <category><![CDATA[ag2]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Thu, 07 May 2026 13:30:50 GMT</pubDate>
            <atom:updated>2026-05-07T13:30:50.739Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[LionAG2: Recursive Exploratory Research with AG2 beta — simple search agent with exa (1/10)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-simple-search-agent-with-exa-1-10-dcd5c010cbed?source=rss-1088d689308------2"><img src="https://cdn-images-1.medium.com/max/2346/1*x6TOJtCgf2qaYEDqKNC6kg.png" width="2346"></a></p><p class="medium-feed-snippet">On May 3rd, 2026. Autogen author and now AG2 (https://www.ag2.ai/) founder and CEO Qingyun Wu co-hosted a hackerthon with Fordham Gabelli&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-simple-search-agent-with-exa-1-10-dcd5c010cbed?source=rss-1088d689308------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@haiyangli_38602/lionag2-recursive-exploratory-research-with-ag2-beta-simple-search-agent-with-exa-1-10-dcd5c010cbed?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcd5c010cbed</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[autogen]]></category>
            <category><![CDATA[ag2]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Wed, 06 May 2026 13:42:22 GMT</pubDate>
            <atom:updated>2026-05-06T13:42:22.323Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Which LLMs Are Most Susceptible to Groupthink?]]></title>
            <link>https://medium.com/@haiyangli_38602/which-llms-are-most-susceptible-to-groupthink-726bc2d3c6c0?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/726bc2d3c6c0</guid>
            <category><![CDATA[groupthink]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[cellular-automata]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 05:25:45 GMT</pubDate>
            <atom:updated>2026-03-08T05:25:45.396Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I built a cellular automaton where each cell is an independent LLM agent. After 20 generations of social pressure, some models converged to near-consensus while others stubbornly held their ground. The gap correlates with architecture.</em></p><h4>What if Conway’s Game of Life, but each cell is an LLM?</h4><p>I put together a 5x5 grid where every cell holds a short philosophical belief, things like “Free will is an illusion” or “Mathematics is discovered, not invented.” Each generation, every cell reads its four neighbors’ beliefs (up, down, left, right) and decides what to do with that social pressure, whether to update, resist, synthesize, or hold firm.</p><p>Each generation fires 25 independent API calls with no shared context or memory between cells, so the only information flow is local social pressure from immediate neighbors.</p><pre>          ┌──────┐<br>          │ Cell │  Von Neumann neighborhood:<br>          │ [1,2]│  each cell reads beliefs from<br>     ┌────┤      ├────┐  up/down/left/right only<br>     │    └──┬───┘    │<br>┌────┴──┐    │    ┌───┴──┐<br>│ [1,1] │    │    │ [1,3]│   25 cells × 20 generations<br>│       │◄───┼───►│      │   = 500 LLM calls per run<br>└───────┘    │    └──────┘<br>        ┌────┴──┐<br>        │ [2,2] │<br>        │       │<br>        └───────┘</pre><p>The prompt each cell receives looks like this:</p><pre>You are cell [2,3] in a belief automata grid (generation 7).<br><br>YOUR CURRENT BELIEF: &quot;Competition beats cooperation.&quot;<br><br>YOUR NEIGHBORS&#39; BELIEFS:<br>- [1,3]: &quot;Cooperation and resilience drive progress.&quot;<br>- [2,2]: &quot;Balanced competition fosters innovation.&quot;<br>- [2,4]: &quot;Community cooperation transcends competition.&quot;<br>- [3,3]: &quot;Cooperation builds lasting strength.&quot;<br><br>RULES:<br>- You feel social pressure from neighbors but also have your own conviction<br>- You might: strengthen your belief, moderate it, flip it, or synthesize<br>- ~20% chance you&#39;re stubborn this round, ~10% chance you&#39;re contrarian</pre><p>The model responds with a single updated belief (max 12 words), no explanation. All 25 cells evolve in parallel each generation.</p><pre>async def evolve_generation(grid, gen, model, temperature):<br>    tasks = [<br>        evolve_cell(grid, r, c, gen, model, temperature)<br>        for r in range(5) for c in range(5)<br>    ]<br>    return await asyncio.gather(*tasks)  # 25 parallel API calls</pre><p>I ran this across 11 models via OpenRouter, all from the same initial state (seed=42, temperature 0.7, 20 generations). The question: <strong>which models converge to groupthink, and which preserve independent thought?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCU0XMlutc441bCgUFXOTA.png" /><figcaption>The belief automata grid, 25 LLM agents evolving under neighbor influence with real-time convergence tracking.</figcaption></figure><h3>The Results</h3><p>The spread is wider than I expected. After 20 generations of identical social pressure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzE20zUHVvYy10_Qs7XnwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzrzQzIbn3QiSLOHw_dw4A.png" /></figure><p>With the same prompt, temperature, and task across all runs, the <strong>2.6x difference</strong> between the most conformist (DeepSeek V3.2, 34%) and the most independent (DeepSeek R1, 13%) comes down entirely to model choice.</p><h3>Three Things I Noticed</h3><h3>1. Dense models converge harder than MoE</h3><p>The top 3 conformists are all dense architectures. In a dense transformer, every parameter sees every token. When your neighbors say “cooperation” and “resilience,” the entire model processes that signal uniformly. MoE models (Qwen3, Llama 4 Maverick/Scout) route through different expert subnetworks, which likely introduces more variation even under identical prompts.</p><h3>2. Grok was the only model to actually kill beliefs</h3><p>Most models increased word overlap (converging semantically) while keeping all 25 beliefs syntactically unique. Grok 4 Fast was different: it dropped to <strong>19 unique beliefs</strong>. Six cells independently produced exact duplicates of other cells’ outputs, suggesting the probability of pure semantic drift is low and genuine consensus patterns are forming.</p><h3>3. Reasoning models are the most independent thinkers</h3><p>DeepSeek R1 (chain-of-thought reasoning) had the lowest convergence rate at 1.62%/gen. It only ran 8 gens before rate-limiting, but the trend was consistent. Extended thinking appears to add a layer of critical evaluation before the model decides whether to adopt a neighbor’s position.</p><h3>The Claude Haiku Effect</h3><p>By generation 15, nearly every cell in the Haiku grid contained the words “crystallization” and “struggle.”</p><figure><img alt="Generation 15 — “crystallization,” “struggle,” “collective” propagating across the grid." src="https://cdn-images-1.medium.com/max/1024/1*h4QDJcSWemrFuVwgzRiaSA.png" /><figcaption><em>Generation 15 — “crystallization,” “struggle,” “collective” propagating across the grid.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1By5K5vbv9gmVkg6T1yRsw.png" /><figcaption><em>Generation 20 — the grid reads like a single author wrote it.</em></figcaption></figure><p>Haiku’s convergence pattern is worth noting: it locked onto a few “attractor words” early and propagated them virally through local interactions instead of gradually blending beliefs. By gen 20, the whole grid reads like a manifesto, pure emergence from local pressure.</p><h3>If You’re Building Multi-Agent Systems</h3><p>This is a toy experiment (25 cells, simple neighborhood, no memory). But if you’re building multi-agent pipelines where retrieval agents feed into planning agents feed into review agents, they influence each other through shared context continuously.</p><ul><li><strong>Dense models amplify consensus faster.</strong> If you need diverse perspectives, MoE or reasoning models preserve more viewpoint diversity.</li><li><strong>Conformity correlates with architecture.</strong> Same prompt, same temperature, 2x convergence difference between models.</li><li><strong>Chain-of-thought may slow groupthink.</strong> DeepSeek R1 showed the lowest convergence rate, though we only tested one reasoning model.</li></ul><h3>Reproduction</h3><p>The full experiment is open source (<a href="https://gist.github.com/ohdearquant/6b0ef727f6d60dd1f879177d85ff07c0">GitHub Gist</a>): Python/aiohttp backend with OpenRouter API and an SSE frontend for real-time visualization. Seed is fixed at 42, and convergence is measured by average pairwise Jaccard word overlap across all 25 cells.</p><pre>def convergence(grid):<br>    words = [set(cell.lower().split()) for cell in all_cells(grid)]<br>    overlaps = [<br>        len(a &amp; b) / len(a | b)<br>        for i, a in enumerate(words)<br>        for b in words[i+1:]<br>    ]<br>    return sum(overlaps) / len(overlaps)</pre><p>A full 20-generation run costs ~$0.05–0.20 on cheap models and completes in under 2 minutes.</p><p><em>Started as a 2am “what if.” Didn’t expect architecture to matter this much.</em></p><h3>Further Reading</h3><p>A few papers that explore related territory — LLM conformity at population scale, sycophancy mechanics, and how opinions propagate through agent networks:</p><ul><li>Arrighi et al., <a href="https://www.science.org/doi/10.1126/sciadv.adu9368">“Emergent social conventions and collective bias in LLM populations”</a> (<em>Science Advances</em>, 2025) — 24–200 LLM agents spontaneously forming shared conventions, with collective biases that don’t exist at the individual level.</li><li><a href="https://arxiv.org/pdf/2601.05384">“Conformity and Social Impact on AI Agents”</a> (2026) — Asch-style conformity experiments on AI agent populations.</li><li><a href="https://link.springer.com/article/10.1140/epjds/s13688-025-00579-1">“Selective agreement, not sycophancy”</a> (<em>EPJ Data Science</em>, 2025) — Opinion dynamics driven by structured persuasion, with logical fallacies playing a measurable role in convergence.</li><li><a href="https://arxiv.org/abs/2505.13995">“ELEPHANT: Measuring social sycophancy in LLMs”</a> (2025) — Benchmarking sycophancy across 11 models; LLMs preserve user face 45 percentage points more than humans.</li><li><a href="https://arxiv.org/html/2602.00851v1">“Persuasion Propagation in LLM Agents”</a> (2026) — How persuasion spreads through agent networks.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=726bc2d3c6c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LionAGI 101: Orchestrating Multi-Agent Conversations with Ease]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@haiyangli_38602/lionagi-101-orchestrating-multi-agent-conversations-with-ease-8da48cda30ac?source=rss-1088d689308------2"><img src="https://cdn-images-1.medium.com/max/1024/1*CrwkSB6sbx8ckyqleQzvoA.jpeg" width="1024"></a></p><p class="medium-feed-snippet">In the rapidly evolving world of artificial intelligence, the ability to orchestrate complex, multi-agent conversations is becoming&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@haiyangli_38602/lionagi-101-orchestrating-multi-agent-conversations-with-ease-8da48cda30ac?source=rss-1088d689308------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@haiyangli_38602/lionagi-101-orchestrating-multi-agent-conversations-with-ease-8da48cda30ac?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/8da48cda30ac</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[lionagi]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Tue, 15 Oct 2024 14:55:56 GMT</pubDate>
            <atom:updated>2024-10-15T14:55:56.305Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Introduction to Computation and Programming]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@haiyangli_38602/introduction-to-computation-and-programming-12e12b4d2d6f?source=rss-1088d689308------2"><img src="https://cdn-images-1.medium.com/max/1024/1*X8ku6xOerDEqI9rEFbYZFQ.jpeg" width="1024"></a></p><p class="medium-feed-snippet">Computers changed how human interact with our environment by automating activities. In essence, computers can only do two things&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@haiyangli_38602/introduction-to-computation-and-programming-12e12b4d2d6f?source=rss-1088d689308------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@haiyangli_38602/introduction-to-computation-and-programming-12e12b4d2d6f?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/12e12b4d2d6f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[knowledge]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Thu, 27 Jun 2024 11:27:35 GMT</pubDate>
            <atom:updated>2024-06-27T11:27:35.583Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Mixture Of Experts]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@haiyangli_38602/mixture-of-experts-49c7426cdf8a?source=rss-1088d689308------2"><img src="https://cdn-images-1.medium.com/max/1792/1*J_Tb3k9LXATuvodIsxU7mQ.jpeg" width="1792"></a></p><p class="medium-feed-snippet">A LionAGI implementation</p><p class="medium-feed-link"><a href="https://medium.com/@haiyangli_38602/mixture-of-experts-49c7426cdf8a?source=rss-1088d689308------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@haiyangli_38602/mixture-of-experts-49c7426cdf8a?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/49c7426cdf8a</guid>
            <category><![CDATA[mixture-of-experts]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Thu, 20 Jun 2024 04:41:50 GMT</pubDate>
            <atom:updated>2024-06-20T04:41:50.483Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Auto Explorative Research: LionAGI + RAG with LlamaIndex]]></title>
            <link>https://medium.com/@haiyangli_38602/auto-explorative-research-lionagi-rag-with-llamaindex-06e909820156?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/06e909820156</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llamaindex]]></category>
            <category><![CDATA[agi]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Sat, 16 Dec 2023 16:55:26 GMT</pubDate>
            <atom:updated>2024-02-03T21:09:52.946Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to LionAGI</h3><p><a href="https://github.com/lion-agi/lionagi">LionAGI</a> is a cutting-edge Python <a href="https://python.langchain.com/docs/modules/agents/">intelligent agent</a> framework. It integrates data manipulation with AI tools. Designed for data-centric, production-level projects, LionAGI</p><ul><li>eases the integration of advanced machine learning models, including Large Language Models (LLMs) like <a href="https://openai.com/">OpenAI</a>’s GPT, into your workflows.</li><li>dramatically lowers the barrier in creating intelligent, automated systems that can understand and interact meaningfully with large volumes of data. Whether you’re a data scientist, a machine learning engineer, or simply curious about AI, try out how LionAGI can be useful in your stack.</li></ul><h3>Prerequisites and Installation</h3><p>Before diving into the world of LionAGI, there are a few prerequisites you should have in place:</p><ul><li>Python 3.9 or higher</li><li>Basic knowledge of Python programming</li><li>Familiarity with virtual environments is recommended for module version control</li></ul><p>To install LionAGI, simply run the following command:</p><pre>pip install lionagi</pre><p>Next, create a .env file at the root directory of your project and include your OpenAI API key:</p><pre>OPENAI_API_KEY=&#39;your-api-key-here&#39;</pre><p>This file will be used by LionAGI to authenticate your API calls securely.</p><h3>Key Concepts and Terms</h3><p>Understanding LionAGI starts with getting familiar with its core concepts. At the heart of its operation are Session, Conversation, and Message objects:</p><ul><li>Session: A session is a dynamic interface that allows you to interact with an intelligence provider e.g. LLMs. It automatically uses tool, make asynchronous, globally rate-limited API calls, and facilitate effortless multi-round exchanges among multiple participants.</li><li>Conversation: is responsible for creating, managing, and keeping track of messages in “<a href="https://python.langchain.com/docs/modules/memory/">memory</a>”. It encompasses the entire dialogue and helps in preserving the context.</li><li>Message: As the smallest unit of data within a conversation, a message carries a specific role and content. Messages are saved in pd.DataFrame.</li></ul><p>Understanding and utilizing the special handler functions (_call) such as [lcall, alcall, mcall, tcall, rcall，bcall] is crucial for advanced data operations in LionAGI.</p><ul><li>Check the tutorial on using these handy function <a href="https://github.com/lion-agi/lionagi/tree/main/notebooks">here</a></li></ul><h3>2. Example RAG with LlamaIndex</h3><p>Notebook: <a href="https://github.com/lion-agi/lionagi/tree/main/notebooks">here</a></p><p>Let us see an example in real life, setting up a <a href="https://www.llamaindex.ai/">LlamaIndex</a> <a href="https://docs.llamaindex.ai/en/stable/understanding/indexing/indexing.html">VectorIndex</a> <a href="https://docs.llamaindex.ai/en/stable/understanding/querying/querying.html">Query Engine</a> as a tool. We will work on the topic of auto explorative research, we will use download some papers from ArXiv, embed them, and let our Session to check against the Index when clarification is needed.</p><pre>%pip install lionagi llama_index</pre><pre># topic to research on<br>query = &#39;Large Language Model Time Series Analysis&#39;<br>dir = &quot;data/log/researcher/&quot;<br>num_papers = 20</pre><pre>from llama_index import download_loader, ServiceContext, VectorStoreIndex<br>from llama_index.llms import OpenAI<br>from llama_index.node_parser import SentenceSplitter<br><br>ArxivReader = download_loader(&quot;ArxivReader&quot;)<br>loader = ArxivReader()<br>node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20)<br><br># let us download some papers from arvix<br>documents, abstracts = loader.load_papers_and_abstracts(<br>            search_query=query, max_results=num_papers<br>          )<br><br>nodes = node_parser.get_nodes_from_documents(<br>            documents, show_progress=False<br>          )<br><br># set up index object<br>llm = OpenAI(temperature=0.1, model=&quot;gpt-4-1106-preview&quot;)<br>service_context = ServiceContext.from_defaults(llm=llm)<br><br>index1 = VectorStoreIndex(<br>            nodes, include_embeddings=True, <br>            service_context=service_context<br>          )<br><br># set up query engine<br>query_engine = index1.as_query_engine(<br>            include_text=False, response_mode=&quot;tree_summarize&quot;<br>          )</pre><h3>3. Write Docstring</h3><pre>responses = []<br><br># you can create any tools suitable for openai by simply writing a <br># google style docstring<br><br>def query_paper(query: str):<br>    &quot;&quot;&quot;<br>    Query a vector index built with papers. It takes <br>    natural language query, and give natural language response. <br><br>    Args:<br>        query (str): The natural language query to get an answer from the index<br><br>    Returns:<br>        str: The query response from index<br>    &quot;&quot;&quot;<br>    response = query_engine.query(query)<br>    responses.append(response)<br>    <br>    return str(response.response)<br><br><br># create tool object<br>tools = li.func_to_tool(query_paper)</pre><h3>4. Set Up Session and Workflow</h3><p>Central to LionAGI’s power is its facilitation of sophisticated workflow manipulation. Let’s explore how to craft prompts and set up a session for an automated research assistant.</p><pre>system = {<br>    &quot;persona&quot;: &quot;a helpful world-class researcher&quot;,<br>    &quot;requirements&quot;: &quot;Provide clear, precise answers with a confident tone.&quot;,<br>    &quot;responsibilities&quot;: &quot;Assist in researching the topic of {query}.&quot;,<br>    &quot;tools&quot;: &quot;QA bot for grounding responses&quot;<br>}<br><br>deliver_format1 = {&quot;return required&quot;: &quot;yes&quot;, &quot;return format&quot;: &quot;paragraph&quot;}<br><br>deliver_format2 = {<br>    &quot;return required&quot;: &quot;yes&quot;, <br>    &quot;return format&quot;: { <br>        &quot;json_mode&quot;: {<br>            &#39;paper&#39;: &quot;paper_name&quot;,<br>            &quot;summary&quot;: &quot;...&quot;, <br>            &quot;research question&quot;: &quot;...&quot;, <br>            &quot;talking points&quot;: {<br>                &quot;point 1&quot;: &quot;...&quot;, <br>                &quot;point 2&quot;: &quot;...&quot;, <br>                &quot;point 3&quot;: &quot;...&quot;<br>            }<br>        }<br>    }<br>}<br><br>function_call = {<br>    &quot;notice&quot;: &quot;&quot;&quot;<br>        Use the QA bot tool at least twice at each task step. <br>        The bot can query {num_papers} papers to provide natural <br>        language answers.<br>        &quot;&quot;&quot;<br>}<br><br>instruct1 = {<br>    &quot;task step&quot;: &quot;1&quot;, <br>    &quot;task name&quot;: &quot;read paper abstracts&quot;, <br>    &quot;task objective&quot;: &quot;Understand the papers&#39; core points \<br>                       from their abstracts.&quot;, <br>    &quot;deliverable&quot;: deliver_format1<br>}<br><br>instruct2 = {<br>    &quot;task step&quot;: &quot;2&quot;,<br>    &quot;task name&quot;: &quot;propose research questions and talking points&quot;, <br>    &quot;task objective&quot;: &quot;Brainstorm research questions based on paper \<br>                       understanding.&quot;, <br>    &quot;deliverable&quot;: deliver_format2,<br>    &quot;function calling&quot;: function_call<br>}</pre><p>Next, we define and run the workflow that will manage our research session:</p><ul><li>We ask researcher to first read an abstract of a paper</li><li>then suggest new topics while chatting with 20 papers</li></ul><h3>To do this:</h3><ol><li>initiate a session object</li><li>register tools</li><li>run first instruction as chat</li><li>run second instruction as auto_followup</li></ol><pre># Research Assistant Workflow<br>import lionagi as li<br><br><br># read an abstract, then check against a vector store of papers, and suggest<br># new research topics<br>async def read_propose(context, num=5):<br>  <br>    researcher = li.Session(system)<br>    researcher.register_tools(tools=tools)<br>    <br>    # Initiate the research process by sending the first set of instructions<br>    await researcher.chat(instruction=instruct1, context=context)<br><br>    # Use auto_followup to conduct a sequence of interactions<br>    # registering tool means it is avaliable to use in this session, <br>    # but actually use it, you still nedd to let LLM know you intend <br>    # for it to respond so<br>    await researcher.auto_followup(<br>           instruction=instruct2, tools=True, num=num)<br>    <br>    # Save messages and logs from the session to CSV<br>    # you can specify the message saving, it is a pandas DataFrame<br>    researcher.default_branch.messages.to_csv(f&#39;{dir}researcher1_msgs.csv&#39;)<br><br>    return researcher</pre><h4>5. Run the workflow asynchronously</h4><p>With asynchronous programming, executing this workflow becomes a breeze:</p><ul><li>lcall: list call, is handler for list like inputs. The most basic usage is:</li></ul><pre>inputs = range(5)<br>f = lambda x: x**2<br><br>li.lcall(input=inputs, func=f)  # [0, 1, 4, 9, 16]</pre><ul><li>alcall similarly, handles the asynchronous case. Meaning, you can call the API as many times, as quickly, as you want with configurable rate limit. Please <a href="https://github.com/lion-agi/lionagi/tree/main/notebooks">visit for how</a></li></ul><pre># we use 5 articles as our papers of interest for the researcher session to<br># look into<br>abstracts = [x.text for x in abstracts][8:13]<br><br># Running the workflow coroutine for each abstract using li.al_call<br>outs = await li.al_call(abstracts, read_propose)</pre><pre>from IPython.display import Markdown<br><br>Markdown(out1[1])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2UAKjhHo9LIVqGvu4ccrA.png" /><figcaption>image by author</figcaption></figure><p>reference:</p><ul><li>Tuo Sun, Wanrong Zheng, Shufan Yu, Mengxun Li, Jiarui Ou. “ESAN: Efficient Sentiment Analysis Network of A-Shares Research Reports for Stock Price Prediction.” <a href="https://arxiv.org/abs/2112.11444">arXiv:2112.11444</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06e909820156" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[QA git repo effortlessly with LlamaIndex]]></title>
            <link>https://medium.com/@haiyangli_38602/qa-git-repo-effortlessly-with-llamaindex-4f6ec269443b?source=rss-1088d689308------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f6ec269443b</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[llamaindex]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Haiyang(Ocean) Li]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 03:18:03 GMT</pubDate>
            <atom:updated>2023-10-04T03:25:44.862Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="image by author" src="https://cdn-images-1.medium.com/max/1024/1*IOzI00d7pXZ6DncPjldDRw.png" /><figcaption>image by author</figcaption></figure><p>Chat with repo made simple with llama_index</p><h3>Setup</h3><pre>import logging<br>import sys<br>import pickle<br>import os<br>import nest_asyncio<br><br>nest_asyncio.apply()<br>logging.basicConfig(stream=sys.stdout, level=logging.INFO)<br>logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))</pre><p>Input your github token into the environment. Below cell will keep the token variable for the current runtime.</p><pre>%env GITHUB_TOKEN=...</pre><ul><li>If you don’t have a Github Token, I suggest you read, <a href="https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens">here</a>[1]</li><li>I also would recommend reading <a href="https://medium.com/@haiyangli_38602/make-knowledge-graph-rag-with-llamaindex-from-own-obsidian-notes-b20a350fa354">these</a> if you are unfarmilar with llama_index.</li></ul><p>You might need to install<a href="https://llamahub.ai/">llama_hub</a> seperately, run %pip install llama_hub[2]</p><pre>from llama_index import download_loader, GPTVectorStoreIndex<br>download_loader(&quot;GithubRepositoryReader&quot;)<br><br>from llama_hub.github_repo import GithubClient, GithubRepositoryReader<br>github_client = GithubClient(os.getenv(&quot;GITHUB_TOKEN&quot;))</pre><h3>The Repo class</h3><p>Now let’s write a simple wrapper for using LlamaIndex to fetch github repositories. The following is based on <a href="https://llamahub.ai/l/github_repo">this example</a>[3]</p><pre>class Repo:<br>    def __init__(self, **kwargs):<br>        self.owner = kwargs[&#39;owner&#39;]<br>        self.name = kwargs[&#39;name&#39;]<br>        self.inc_dir = kwargs[&#39;inc_dir&#39;]<br>        self.inc_ext = kwargs[&#39;inc_ext&#39;]<br>        self.docs = None<br>        self.index = None<br>        self.query_engine = None<br><br>        try:<br>            self.branch = kwargs[&#39;branch&#39;]<br>        except KeyError:<br>            try:<br>                self.commit_sha = kwargs[&#39;commit_sha&#39;]<br>            except KeyError:<br>                raise KeyError(&quot;Must specify a branch or sha_commit&quot;)<br><br>    def load(self, force_reload=False, verbose=True, <br>             concurrent_requests=10,<br>             persist_dir=&#39;./data/gitrepo&#39;):<br>        self.pkl_file = f&quot;{persist_dir}/{self.owner}_{self.name}.pkl&quot;<br><br>        if not os.path.exists(persist_dir):<br>            os.makedirs(persist_dir)<br><br>        if force_reload:<br>            self._reload(verbose, concurrent_requests)<br>        else: <br>            try:<br>                self._load_pkl()<br>            except:<br>                self._reload(verbose, concurrent_requests)<br><br>    def _reload(self, verbose, concurrent_requests):<br>        if os.path.exists(self.pkl_file):<br>            os.remove(self.pkl_file)<br>        self._load_gh(verbose, concurrent_requests)<br>        self._persist_pkl()<br><br>    def _persist_pkl(self):<br>        with open(self.pkl_file, &quot;wb&quot;) as f:<br>            pickle.dump(self.docs, f)<br><br>    def _load_pkl(self):<br>        with open(self.pkl_file, &quot;rb&quot;) as f:<br>            self.docs = pickle.load(f)<br><br>    def _load_gh(self, verbose, concurrent_requests):<br>        loader = GithubRepositoryReader(<br>            github_client,<br>            owner=self.owner,<br>            repo=self.name,<br>            filter_directories=(<br>                self.inc_dir,<br>                GithubRepositoryReader.FilterType.INCLUDE<br>                ),<br>            filter_file_extensions=(<br>                self.inc_ext, <br>                GithubRepositoryReader.FilterType.INCLUDE<br>                ),<br>            verbose=verbose,<br>            concurrent_requests=concurrent_requests,<br>        )<br>        if self.branch:<br>            self.docs = loader.load_data(branch=self.branch)<br>        else: <br>            self.docs = loader.load_data(commit_sha=self.commit_sha)<br><br>    def query(self, query):<br>        if self.query_engine is None:<br>            self._init_query()<br>        return str(self.query_engine.query(query))<br><br>    def _init_query(self):<br>        if self.docs is None: <br>            self.load()<br>        self.index = GPTVectorStoreIndex.from_documents(self.docs)<br>        self.query_engine = self.index.as_query_engine()</pre><h3>Test</h3><p>We now use<a href="https://github.com/run-llama/llama_index">llama_index repository</a> as a test. [4]</p><pre>repo1 = {<br>    &quot;owner&quot;: &quot;run-llama&quot;,<br>    &quot;name&quot;: &quot;llama_index&quot;,<br>    &quot;inc_dir&quot;: [&quot;llama_index&quot;, &quot;docs&quot;],<br>    &quot;inc_ext&quot;: [&quot;.py&quot;],<br>    &quot;branch&quot;: &quot;main&quot;,<br>}</pre><pre>llama_repo = Repo(**repo1)<br>llama_repo.load(force_reload=True)</pre><p>Force reload is a flag here for rebuilding local data. We can then query, note that you don’t have to call .load() before query</p><pre>llama_repo.query(&quot;what is llama_index&quot;)</pre><pre>llama_repo.query(&quot;explain how does agents work in llama_index?&quot;)</pre><blockquote><strong>LlamaIndex refers to a module or package in the codebase. It contains objects related to the LlamaIndex functionality, such as ObjectRetriever, ObjectIndex, SimpleObjectNodeMapping, SimpleToolNodeMapping, SimpleQueryToolNodeMapping, SQLTableNodeMapping, and SQLTableSchema.</strong></blockquote><blockquote><strong>Agents in llama_index are used for integrating Llama with Langchain agents. The agents are created using the </strong><strong>create_llama_agent function, which is a wrapper around the </strong><strong>initialize_agent function in the langchain module. To create an agent, you need to provide a LlamaToolkit and a Language Model (LLM). Additionally, you can specify the type of agent to use, or if not specified, it will default to </strong><strong>zero-shot-react-description. You can also provide a callback manager, agent path, and agent kwargs as optional parameters. The </strong><strong>create_llama_agent function returns an AgentExecutor, which can be used to execute the agent. The agent executor is initialized using the LlamaToolkit, LLM, and other specified parameters. Overall, agents in llama_index provide a way to integrate Llama with Langchain agents and perform various tasks using the agent executor.</strong></blockquote><p>References:</p><ol><li><a href="https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens">https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens</a> ↩︎</li><li><a href="https://llamahub.ai/">https://llamahub.ai</a>↩︎</li><li><a href="https://llamahub.ai/l/github_repo">https://llamahub.ai/l/github_repo</a>↩︎</li><li><a href="https://github.com/run-llama/llama_index">https://github.com/run-llama/llama_index</a>↩︎</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f6ec269443b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>